コード例 #1
0
ファイル: LogController.php プロジェクト: pawansgi92/pimcore2
 public function setAction()
 {
     $owner = $_POST['user'];
     $activities = $_POST['activities'];
     $object = $_POST['object'];
     $isValid = Website_P1GlobalFunction::checkValidation($_POST, array('user', 'activities', 'object'));
     if (count($isValid) > 0) {
         $arrayReturn = array("status" => "failed", "message" => "field not found", "data" => $isValid);
         $json_plans = $this->_helper->json($arrayReturn);
         Website_P1GlobalFunction::sendResponse($json_plans);
         exit;
     }
     $ownerId = Object_Abstract::getById($owner);
     $activitiesId = Object_Abstract::getById($activities);
     $key = str_replace(' ', '_', strtolower($ownerId->Name)) . "-" . str_replace(' ', '_', strtolower($activitiesId->Name) . "-" . rand());
     $now = date("Y-m-d,H-i");
     $getDateTime = new Pimcore_Date($now);
     if ($ownerId->o_className == "Customer") {
         $getId = Object_Abstract::getByPath('/log/customers');
         //get folder id
         $setLog = new Object\LogCustomers();
         $setLog->setCustomers($ownerId);
         $setLog->setActivities($activitiesId);
         $setLog->setObjectContent($object);
         $setLog->setDatetime($getDateTime);
         $setLog->setO_parentId($getId->o_id);
         $setLog->setKey($key);
         $setLog->setPublished(1);
         $setLog->save();
         $status = "Success";
         $message = "Success";
         $data = "Add Customer log Success";
     } else {
         if ($ownerId->o_className == "Agen") {
             $getId = Object_Abstract::getByPath('/log/agen');
             //get folder id
             $setLog = new Object\LogAgents();
             $setLog->setAgen($ownerId);
             $setLog->setActivities($activitiesId);
             $setLog->setObjectContent($object);
             $setLog->setDatetime($getDateTime);
             $setLog->setO_parentId($getId->o_id);
             $setLog->setKey($key);
             $setLog->setPublished(1);
             $setLog->save();
             $status = "Success";
             $message = "Success";
             $data = "Add Agen log Success";
         } else {
             $status = "Field";
             $message = "Log id not found";
             $data = "Null";
         }
     }
     $arrayReturn = array("status" => $status, "message" => $message, "data" => $data);
     $json_log = $this->_helper->json($arrayReturn);
     Website_P1GlobalFunction::sendResponse($json_log);
 }
コード例 #2
0
 public function getAction()
 {
     $idstore = $_POST['idstore'];
     $orderby = $_POST['orderby'];
     $store = array();
     $stores = array();
     $return = array();
     $isValid = Website_P1GlobalFunction::checkValidation($_POST, array('idstore', 'orderby'));
     if (count($isValid) > 0) {
         $arrayReturn = array("status" => "failed", "message" => "field not found", "data" => $isValid);
         $json_plans = $this->_helper->json($arrayReturn);
         Website_P1GlobalFunction::sendResponse($json_plans);
         exit;
     }
     if ($orderby != "" or $idstore != "") {
         $field = array("o_id", "name", "address", "longitude", "latitude");
         //default paramter
         if (!in_array($orderby, $field)) {
             //field is true check in array or not
             $orderby = "name";
         }
         $setOrderKey = $orderby;
         $getStore = new Object\Stores\Listing();
         if (isset($idstore)) {
             $getStore->setCondition("o_id='" . $idstore . "'");
         }
         $getStore->setOrderKey($setOrderKey);
         $i = 0;
         foreach ($getStore as $key) {
             $store[$i] = array("o_id" => $key->o_id, "name" => $key->name, "address" => $key->address, "longitude" => $key->addressPoints->longitude, "latitude" => $key->addressPoints->latitude);
             $i++;
         }
         if (isset($i) and $i < 0) {
         }
         $stores["status"] = "success";
         $stores["message"] = "success";
         $stores["data"] = $store;
         array_push($return, $stores);
     } else {
         $return = array("status" => "failed", "message" => "Paramter invalid, parameter orderby can't empty (is requred) !", "date" => "");
     }
     $json_store = $this->_helper->json($return);
     Website_P1GlobalFunction::sendResponse($json_store);
 }
コード例 #3
0
 public function getstockAction()
 {
     $id_product = $_GET['id_product'];
     $isValid = Website_P1GlobalFunction::checkValidation($_GET, array('id_product'));
     if (count($isValid) > 0) {
         $arrayReturn = array("status" => "failed", "message" => "field not found", "data" => $isValid);
         $json_plans = $this->_helper->json($arrayReturn);
         Website_P1GlobalFunction::sendResponse($json_plans);
         exit;
     }
     $stocks = new Object\Stocks\Listing();
     if ($id_product != "") {
         $stocks->setCondition("product__id='" . $id_product . "'");
     }
     $stocks->setOrderKey("count");
     $stocks->setOrder("desc");
     $i = 0;
     foreach ($stocks as $key => $value) {
         # code...
         $stock[$i] = array('o_id' => $value->o_id, 'product' => array('product_id' => $value->product->o_id, 'name' => $value->product->name, 'slugName' => $value->product->slugName, 'price' => $value->product->price->items[0], 'images' => $value->product->images, 'deviceModel' => $value->product->deviceModel, 'is_small_product' => $value->product->is_small_product, 'is_large_product' => $value->product->is_large_product, 'description' => $value->product->description, 'rrp' => $value->product->rrp), 'stores' => array('product_id' => $value->product->o_id, 'name' => $value->product->name, 'address' => $value->product->slugName, 'addressPoints' => array('longitude' => $value->stores->addressPoints->longitude, 'latitude' => $value->stores->addressPoints->latitude)), 'count' => $value->count, 'inOrder' => $value->inOrder, 'time_dmp_updated' => $value->o_id);
         $i++;
         $message = "success";
     }
     if ($i < 1) {
         $message = "product id not found";
     }
     $arrayReturn = array("status" => "success", "message" => $message, "data" => $stock);
     $json_stock = $this->_helper->json($arrayReturn);
     Website_P1GlobalFunction::sendResponse($json_stock);
 }