Example #1
0
 function productAjax()
 {
     $uriCount = $this->uri->total_segments();
     $data = array('status' => FALSE);
     if ($uriCount > 1) {
         switch ($this->uri->segment(2)) {
             case 'newest':
                 $data['bestsell'] = $this->Product_Model->itemRandom('bestsell', 8, true);
                 $data['new'] = $this->Product_Model->itemRandom('new', 8, false);
                 $data['special'] = $this->Product_Model->itemRandom('special', 8, false);
                 $data['featured'] = $this->Product_Model->itemRandom('featured', 8, false);
                 $data['status'] = TRUE;
                 break;
             case 'related':
                 $items = $this->Product_Model->itemRandom('bestsell', 6, true);
                 if ($items) {
                     $data['status'] = true;
                     $data['related'] = $items;
                 }
                 break;
             default:
                 $items = $this->Product_Model->items($this->uri->segment($uriCount), 'id', $this->input->get('c'), 9);
                 if ($items) {
                     $data['status'] = true;
                     $data['items'] = $items;
                 }
                 break;
         }
     } else {
         $items = $this->Product_Model->items($this->uri->segment($uriCount), 'id', $this->input->get('c'), 9);
         if ($items) {
             $data['status'] = true;
             $data['items'] = $items;
         }
     }
     return jsonData($data);
     exit;
 }
Example #2
0
 private function formAction($field, $id = null)
 {
     $this->backpak->formField = $field;
     switch ($this->action) {
         case 'add-new':
             $this->backpak->form();
             break;
         case 'update':
             $id = $id ? $id : $this->uri->segment(3);
             $this->backpak->form(array('id' => $id));
             break;
         case 'publish':
         case 'remove':
             switch ($this->backpak->formItemName) {
                 case 'Customer':
                     $table = Pak_Model::$userTable;
                     break;
                 case 'Order':
                     $table = Pak_Model::$orderTable;
                     break;
                 case 'Note':
                     $table = Pak_Model::$noteTable;
                     break;
                 default:
                     $table = null;
                     break;
             }
             if ($this->input->post()) {
                 //					$table = strtolower($this->backpak->formItemName).'Table';
                 $data = array('id' => $this->input->post('id'), 'status' => $this->input->post('publish'));
                 jsonData(array('action' => $this->Pak_Model->update($data, $table) ? true : false));
             }
         default:
             show_404();
             break;
     }
 }
Example #3
0
 public function dataTableAjax($aColumns, $sWhere = null, $model = 'ICT_Model', $getDataFunction = null)
 {
     self::datatableAjaxSetCache('iDisplayStart');
     self::datatableAjaxSetCache('iDisplayLength');
     $coumnValue = array_values($aColumns);
     if (!is_string($coumnValue[0])) {
         $aColumns = array_keys($aColumns);
     }
     if (!isset($getDataFunction) || !$getDataFunction) {
         $getDataFunction = strtolower($this->formItemName) . 'Ajax';
     }
     $sStart = $sLength = 0;
     $sStart = $this->CI->input->post('iDisplayStart');
     $sLength = $this->CI->input->post('iDisplayLength');
     //$showFor = $this->CI->input->get('show');
     $sOrder = "";
     for ($i = 0; $i < intval($this->CI->input->post('iSortingCols')); $i++) {
         if ($this->CI->input->post('bSortable_' . intval($this->CI->input->post('iSortCol_' . $i))) == "true") {
             $sOrder .= $aColumns[intval($this->CI->input->post('iSortCol_' . $i))] . " " . ($this->CI->input->post('sSortDir_' . $i) === 'asc' ? 'asc' : 'desc') . ", ";
         }
     }
     $sOrder = substr_replace($sOrder, "", -2);
     $fields = $aColumns;
     unset($fields[count($fields) - 1]);
     $data = $this->CI->{$model}->{$getDataFunction}($sStart, $sLength, $sOrder, $sWhere, $fields);
     $dataReturn = array("sEcho" => $this->CI->input->post('sEcho'), "iTotalRecords" => $data['totalRecords'], "iTotalDisplayRecords" => $data['totalRecords'], "aaData" => $data['data']);
     return jsonData($dataReturn);
 }