コード例 #1
0
 public function getIndex()
 {
     $this->title = 'Manifest Pengiriman Harian - Retur';
     $this->place_action = 'none';
     $this->show_select = false;
     $this->can_add = false;
     $this->is_report = true;
     Breadcrumbs::addCrumb('Manifest', URL::to(strtolower($this->controller_name)));
     $this->additional_filter = View::make(strtolower($this->controller_name) . '.addfilter')->with('submit_url', 'manifest')->render();
     $db = Config::get('lundin.main_db');
     $company = Input::get('acc-company');
     //device=&courier=&logistic=&date-from=2015-10-24
     $period_from = Input::get('date-from');
     $period_to = Input::get('date-to');
     $device = Input::get('device');
     $courier = Input::get('courier');
     $logistic = Input::get('logistic');
     $position = Input::get('position');
     $trip = Input::get('trip');
     $status = Input::get('status');
     $courierstatus = Input::get('courier-status');
     if ($period_to == '' || is_null($period_to)) {
         $period_to = date('Y0m', time());
     }
     $this->def_order_by = 'TRANS_DATETIME';
     $this->def_order_dir = 'DESC';
     $this->place_action = 'none';
     $this->show_select = false;
     /* Start custom queries */
     $model = $this->model;
     if ($status == '' || is_null($status)) {
         $status = Config::get('jayon.manifest_default_status');
         $status[] = Config::get('jayon.trans_status_mobile_return');
     } else {
         $status = explode(',', $status);
     }
     if (empty($status)) {
         $exstatus = Config::get('jayon.manifest_default_excl_status');
         if (!empty($exstatus)) {
             $model = $model->whereNotIn('status', $exstatus);
         }
     } else {
         $model = $model->whereIn('status', $status);
     }
     if ($courierstatus == '' || is_null($courierstatus)) {
         $courierstatus = Config::get('jayon.manifest_default_courier_status');
     } else {
         $courierstatus = explode(',', $courierstatus);
     }
     if (empty($courierstatus)) {
         $excrstatus = Config::get('jayon.manifest_default_excl_courier_status');
         if (!empty($excrstatus)) {
             $model = $model->whereNotIn('courier_status', $excrstatus);
         }
     } else {
         $model = $model->whereIn('courier_status', $courierstatus);
     }
     if ($period_from == '' || is_null($period_from)) {
         $def_from = date('Y-m-d', time());
         $model = $model->where('pick_up_date', '=', new MongoDate(strtotime($def_from)));
     } else {
         $model = $model->where('pick_up_date', '=', new MongoDate(strtotime($period_from)));
     }
     if ($device == '' || is_null($device)) {
     } else {
         $model = $model->where('device_key', '=', $device);
     }
     if ($courier == '' || is_null($courier)) {
     } else {
         $model = $model->where('courier_id', '=', $courier);
     }
     if ($logistic == '' || is_null($logistic)) {
     } else {
         $model = $model->where('logistic', '=', $logistic);
     }
     if ($position == '' || is_null($position)) {
     } else {
         $model = $model->where('position', '=', $position);
     }
     if ($trip == '' || is_null($trip)) {
     } else {
         $model = $model->where(function ($t) use($trip) {
             $t->where('trip', '=', intval($trip))->orWhere('trip', '=', strval($trip));
         });
     }
     $actualresult = $model->get();
     $tattrs = array('width' => '100%', 'class' => 'table table-bordered table-striped');
     $thead = array();
     //No. Kota Type Status  KEPADA  ALAMAT  Phone   Order ID Fulfillment ID Jumlah Box PENERIMA PAKET
     //TANDA TANGAN    NAMA
     $thead[] = array(array('value' => '#', 'attr' => 'rowspan=2'), array('value' => 'Delivery Date', 'attr' => 'rowspan="2" '), array('value' => 'Kota', 'attr' => 'rowspan="2" class="center"'), array('value' => 'Type', 'attr' => 'rowspan="2" '), array('value' => 'Logistic', 'attr' => 'rowspan="2" '), array('value' => 'Device', 'attr' => 'rowspan="2" '), array('value' => 'Status', 'attr' => 'rowspan="2" '), array('value' => 'KEPADA / CUSTOMER', 'attr' => 'rowspan="2" '), array('value' => 'ALAMAT', 'attr' => 'rowspan="2" style="min-width:200px;"'), array('value' => 'Telepon', 'attr' => 'rowspan="2" '), array('value' => 'Order ID', 'attr' => 'rowspan="2" '), array('value' => 'Fulfillment ID', 'attr' => 'rowspan="2" '), array('value' => 'Nilai COD', 'attr' => 'rowspan="2" '), array('value' => 'Jumlah Paket', 'attr' => 'rowspan="2" '), array('value' => 'PENERIMA', 'attr' => 'colspan="4"'));
     $thead[] = array(array('value' => 'JUMLAH DITERIMA DI HUB', 'attr' => ''), array('value' => 'TANGGAL / JAM TERIMA', 'attr' => ''), array('value' => 'TANDA TANGAN', 'attr' => ''), array('value' => 'NAMA', 'attr' => 'class="bold center" style="width:50px" '));
     $seq = 1;
     $tabdata = array();
     foreach ($actualresult as $m) {
         if ($m->pick_up_date instanceof MongoDate) {
             $pick_up_date = date('Y-m-d H:i:s', $m->pick_up_date->sec);
             $dattr = '';
         } else {
             $pick_up_date = $m->pick_up_date;
             $dattr = 'class="red"';
         }
         $tabdata[] = array(array('value' => $seq, 'attr' => ''), array('value' => $pick_up_date, 'attr' => $dattr), array('value' => $m->consignee_olshop_city, 'attr' => ''), array('value' => $m->delivery_type, 'attr' => ''), array('value' => $m->logistic, 'attr' => ''), array('value' => $m->device_name, 'attr' => ''), array('value' => Prefs::translatestatus($m->status, 'delivery'), 'attr' => ''), array('value' => $m->consignee_olshop_name, 'attr' => ''), array('value' => $m->consignee_olshop_addr, 'attr' => ''), array('value' => $m->consignee_olshop_phone, 'attr' => ''), array('value' => $m->no_sales_order, 'attr' => ''), array('value' => $m->consignee_olshop_orderid, 'attr' => ''), array('value' => Ks::idr($m->cod), 'attr' => 'style="text-align:right;"'), array('value' => $m->number_of_package, 'attr' => ''), array('value' => '', 'attr' => ''), array('value' => '', 'attr' => ''), array('value' => '', 'attr' => ''), array('value' => '', 'attr' => ''));
         $seq++;
     }
     $mtable = new HtmlTable($tabdata, $tattrs, $thead);
     $tables[] = $mtable->build();
     $this->table_raw = $tables;
     if ($this->print == true || $this->pdf == true || $this->xls == true) {
         return $tables;
     } else {
         return parent::reportPageGenerator();
     }
 }