load->database(); $this->load->helper('date'); $this->load->model('FxForm_model'); $this->load->model('Config_model'); } public function mod_getRecords($rowno, $rowperpage, $filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif = 1, $langue = 'fr') { // list la bb client $this->db->select('*'); $this->db->from('usa_usagers'); $this->db->where('usa_actif', $listactif); // if ($filtre1 != "") // $this->db->where("des_nom_fr LIKE '%$filtre1%'"); // if ($filtre2 != "") // $this->db->where("des_description_fr LIKE '%$filtre2%'"); // if ($filtre3 != "") // $this->db->where("des_ref_type = " . $filtre3); $this->db->limit($rowperpage, $rowno); $this->db->order_by("usa_nom"); $query = $this->db->get(); return $query->result_array(); } public function mod_getRecordCountfilter($filtre1 = "", $filtre2 = "", $filtre3 = "", $listactif) { $this->db->select('count(*) as allcount'); $this->db->from('pro_descriptions'); $this->db->where('des_actif', $listactif); if ($filtre1 != "") $this->db->where("des_nom_fr LIKE '%$filtre1%'"); if ($filtre2 != "") $this->db->where("des_description_fr LIKE '%$filtre2%'"); if ($filtre3 != "") $this->db->where("des_ref_type = " . $filtre3); $query = $this->db->get(); $result = $query->result_array(); return $result[0]['allcount']; } public function mod_getRecord($id, $langue = 'fr') { // trouve un enregiestrement $this->db->select('*'); $this->db->from('usa_usagers'); $this->db->where('usa_id=' . $id); $this->db->limit(1); $query = $this->db->get(); return $query->row(); } public function mod_saveRecordbd($id, $data, $pref) { // creation de la chaine de save $mem_data = array(); // ajoute les checkbox if (!isset($data['com_actif'])) $data['com_actif'] = 0; foreach ($data as $key => $value) { if (substr($key, 0, strlen($pref)) == $pref) { $mem_data[$key] = $value; } } $mem_data['com_modif'] = date("Y-m-d H:i:s"); $mem_where = "com_id =" . $id; $str = $this->db->update('cli_compte', $mem_data, $mem_where); $ok = true; return $ok; } public function mod_desactivateRecordbd($id, $statut) { // creation de la chaine de save $mem_data = array(); $mem_data['usa_actif'] = $statut; $mem_where = "usa_id =" . $id; $str = $this->db->update('usa_usagers', $mem_data, $mem_where); $ok = true; return $ok; } public function mod_createRecordbd($data, $pref, $id) { // creation de la chaine de save $mem_data = array(); if (!isset($data['usa_representant'])) $data['des_tps']=0; foreach ($data as $key => $value) { if (substr($key, 0, strlen($pref)) == $pref) { $mem_data[$key] = $value; } } if ($id == 0) { if ($mem_data['usa_login']!=""){ $mem_data['usa_creation'] = date("Y-m-d H:i:s"); $mem_data['usa_actif'] = 1; $str = $this->db->insert('usa_usagers', $mem_data);} } else { $mem_where = "usa_id =" . $id; $str = $this->db->update('usa_usagers', $mem_data, $mem_where); } $ok = true; return $this->db->insert_id(); } public function mod_getRecordCount() { $this->db->select('count(*) as allcount'); $this->db->from('pro_descriptions'); $this->db->where('des_actif', 1); $query = $this->db->get(); $result = $query->result_array(); return $result[0]['allcount']; } public function mod_getforminfo($id) { global $mem_data, $validation; $this->load->model('Config_model'); $this->load->model('FxForm_model'); // vas chercher les info de la fiche if ($id != 0) $info = $this->mod_getRecord($id); // prepare info pour chaque champs utilisé // input $mem_data['mem_id'] = $id; $mem_champ = 'usa_prenom'; $mem_value = ($id == 0 ? '' : $info->$mem_champ); $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Prénom', ''); $this->FxForm_model->fxvaliderequired($mem_champ); // ------------------------------------------------------------------------- $mem_champ = 'usa_nom'; $mem_value = ($id == 0 ? '' : $info->$mem_champ); $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Nom', ''); $this->FxForm_model->fxvaliderequired($mem_champ); // ------------------------------------------------------------------------- $mem_champ = 'usa_login'; $mem_value = ($id == 0 ? '' : $info->$mem_champ); $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Login', ''); $this->FxForm_model->fxvaliderequired($mem_champ); // ------------------------------------------------------------------------- $mem_champ = 'usa_password'; $mem_value = ($id == 0 ? '' : $info->$mem_champ); $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Mot de passe', ''); $this->FxForm_model->fxvaliderequired($mem_champ); // ------------------------------------------------------------------------- $mem_champ = 'usa_telephone'; $mem_value = ($id == 0 ? '' : $info->$mem_champ); $this->FxForm_model->fxinputtxt($mem_champ, $mem_value, 'Téléphone', ''); $this->FxForm_model->fxvaliderequired($mem_champ); $mem_champ='usa_representant'; $mem_value=($id==0 ? true : ($info->$mem_champ==1 ? true:false)); $mem_data['checkbox'][$mem_champ] = array( 'name' => $mem_champ, 'value' => 1, 'checked' => $mem_value, ); $mem_data['label'][$mem_champ] = 'Répresentant'; $mem_data['icon'][$mem_champ] = ' '; // ------------------------------------------------------------------------- $mem_data['validation'] = $this->FxForm_model->fxValidation($validation['rule'], $validation['message']); return $mem_data; } public function mod_loadData_list($record = 0, $filtre1 = '', $filtre2 = '', $filtre3 = '', $listactif = 1, $model_de_produits) { $filtre1 = ($filtre1 == 'null' ? '' : $filtre1); $filtre2 = ($filtre2 == 'null' ? '' : $filtre2); $filtre3 = ($filtre3 == 'null' ? '' : $filtre3); if ($model_de_produits == "liste") $recordPerPage = 50; else $recordPerPage = 5; $config["cur_page"] = $record; if ($record != 0) { $record = ($record - 1) * $recordPerPage; } $recordCount2 = $this->mod_getRecordCount(); $recordCount = $this->mod_getRecordCountfilter($filtre1, $filtre2, $filtre3, $listactif); $client_list = $this->mod_getRecords($record, $recordPerPage, $filtre1, $filtre2, $filtre3, $listactif); $config['base_url'] = base_url() . 'index.php/Produits/loadData_list'; $config['use_page_numbers'] = TRUE; $config['next_link'] = 'Next'; $config['prev_link'] = 'Previous'; //$config['total_rows'] = $recordCount; $config['total_rows'] = 1; $config['per_page'] = $recordPerPage; $choice = $config["total_rows"] / $config["per_page"]; $config["uri_segment"] = 2; $config["num_links"] = 2; $config['full_tag_open'] = '
| ', 'heading_cell_end' => ' | ', 'tbody_open' => '', 'tbody_close' => '', 'row_start' => '
|---|
| ', 'cell_end' => ' | ', 'row_alt_start' => '
| ', 'cell_alt_end' => ' | ', 'table_close' => '