Exemplo n.º 1
0
 function edit($id = 0)
 {
     $khachhang = new khachhang($id);
     if ($_SERVER['REQUEST_METHOD'] == "GET") {
     } else {
         $file = 'img/logo/';
         $position = $this->input->post('position');
         $partner = new Khachhang();
         $partner->where('position >', $position);
         $partner->get()->all;
         foreach ($partner as $row) {
             $row->position = $row->position + 1;
             $row->save();
             $row->clear();
         }
         $this->load->library('file_lib');
         $khachhang->name_vietnamese = $this->input->post('name');
         $khachhang->description = $this->input->post('description');
         $khachhang->link = $this->input->post('link');
         $khachhang->address = $this->input->post('address');
         $khachhang->email = $this->input->post('email');
         $khachhang->phone = $this->input->post('phone');
         $khachhang->position = $position;
         $dataupload = $this->file_lib->upload('image', $file);
         if (!is_array($dataupload)) {
             flash_message('info', $dataupload);
         } else {
             $khachhang->logo = $file . $dataupload['file_name'];
             $this->resize_image('img/partner/' . $dataupload['file_name']);
         }
         if ($khachhang->save()) {
             redirect($this->admin . 'partner/edit/' . $khachhang->id);
         }
     }
     $dis['base_url'] = base_url();
     $dis['title'] = "Add/Edit Language";
     $dis['menu_active'] = "Đối tác";
     $dis['view'] = "khachhang/edit";
     $dis['object'] = $khachhang;
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Back", "link" => "{$this->admin_url}partner", "onclick" => ""));
     $this->viewadmin($dis);
 }
Exemplo n.º 2
0
 function down_position()
 {
     $min = new khachhang();
     $min->select_min('position');
     $min->where('position >', $this->position);
     $min->get();
     $o = new khachhang();
     $o->where('position', $min->position);
     $o->get();
     if ($o->result_count() > 0) {
         $tg = $this->position;
         $this->position = $o->position;
         $o->position = $tg;
         $o->save();
         $this->save();
         return true;
     } else {
         return false;
     }
 }