82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
<?php
|
|
|
|
class CpeshippingController extends mfBaseController {
|
|
|
|
protected function init() {
|
|
$this->needlogin=true;
|
|
$me = new User();
|
|
$me->loadMe();
|
|
$this->me = $me;
|
|
$this->layout()->set("me",$me);
|
|
|
|
if(!$me->is(["Admin"])) {
|
|
$this->redirect("Dashboard");
|
|
}
|
|
}
|
|
|
|
protected function indexAction() {
|
|
$this->layout()->setTemplate("Cpeshipping/Index");
|
|
|
|
// pagination defaults
|
|
$pagination = [];
|
|
$pagination['start'] = 0;
|
|
$pagination['count'] = 25;
|
|
$pagination['maxItems'] = 0;
|
|
|
|
if(is_numeric($this->request->s)) {
|
|
$pagination['start'] = intval($this->request->s);
|
|
}
|
|
|
|
$provisions_search = ["shipping" => 1, "shipped" => 0];
|
|
|
|
$pagination['maxItems'] = CpeprovisioningModel::count($provisions_search);
|
|
$provisions = CpeprovisioningModel::search($provisions_search, $pagination);
|
|
//$o = $provisions[0]->orderproduct->product->attributes;
|
|
//var_dump($o);exit;
|
|
$this->layout()->set("cpeprovisionings", $provisions);
|
|
$this->layout()->set("pagination", $pagination);
|
|
|
|
}
|
|
|
|
protected function shipAction() {
|
|
//$this->redirect("Cpeshipping");
|
|
$r = $this->request;
|
|
//var_dump($r);exit;
|
|
|
|
|
|
if(is_array($r->ships) && count($r->ships)) {
|
|
$ships = $r->ships;
|
|
}
|
|
|
|
$shippings = [];
|
|
|
|
foreach($ships as $prov_id) {
|
|
if(!is_numeric($prov_id) || $prov_id <= 0) {
|
|
continue;
|
|
}
|
|
|
|
$prov = new Cpeprovisioning($prov_id);
|
|
|
|
if(!$prov->id) {
|
|
continue;
|
|
}
|
|
if(!$prov->shipping) {
|
|
// is not supposed to be selectable in UI
|
|
continue;
|
|
}
|
|
$shippings[] = $prov;
|
|
}
|
|
|
|
$tpl = new Layout();
|
|
$tpl->setTemplate("Cpeshipping/csv/dhl.csv");
|
|
$tpl->set("shippings", $shippings);
|
|
$tpl->set("me", $this->me);
|
|
$body = $tpl->render();
|
|
|
|
//$values = $tpl->getReturnedValue();
|
|
|
|
header("Content-type: text/csv");
|
|
echo $body;exit;
|
|
|
|
}
|
|
} |