예제 #1
0
 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 logoutAction()
 {
     $username = $_POST['username'];
     $return_array = array();
     $data;
     if (!empty($username)) {
         $customer = new Object\Customer\Listing();
         $customer->setCondition("username = ?", array($username));
         foreach ($customer as $value) {
             session_start();
             session_destroy();
             $data = array("username" => $value->username);
             $return_array['status'] = 'success';
             $return_array['message'] = 'Logout success';
             $return_array['data'] = $data;
         }
     } else {
         $return_array['status'] = 'failed';
         $return_array['message'] = 'This user has been logout';
         $return_array['data'] = '';
     }
     $json_customer = $this->_helper->json($return_array);
     Website_P1GlobalFunction::sendResponse($json_customer);
     $this->sendResponse($json_customer);
 }
예제 #4
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);
 }
예제 #5
0
 public function getAction()
 {
     $id_review = $_POST['id_review'];
     $id_product = $_POST['id_product'];
     $return_array = array();
     $data;
     // $isValid=Website_P1GlobalFunction::checkValidation($_POST,array('id_review'));
     // if(count($isValid)>0){
     //     $return_array = array(
     //             "status" => "failed",
     //             "message" => "field not found",
     //             "data" => $isValid
     //     );
     //     $json_review = $this->_helper->json($return_array);
     //     Website_P1GlobalFunction::sendResponse($json_review);
     //     exit();
     // }
     //     $return_array['data']       = '';
     // if( $id_review == "")
     // {
     //     $return_array['status']     = 'failed';
     //     $return_array['message']    = 'Review ID is required';
     // }
     // else
     // {
     $review = new Object\Review\Listing();
     $review->setCondition("oo_id = '{$id_review}' ");
     $i = 0;
     foreach ($review as $value) {
         // print_r($value);
         $data[$i++] = array("rating" => $value->rating, "creationDate" => $value->o_creationDate, "description" => $value->description, "productID" => $value->product->o_id, "customerID" => $value->customer->o_id, "customerName" => $value->customer->name, "customerUsername" => $value->customer->username);
         // print_r($value);
     }
     // }
     $return_array['status'] = 'Success';
     $return_array['message'] = 'Success';
     $return_array['data'] = $data;
     // die();
     $json_review = $this->_helper->json($return_array);
     Website_P1GlobalFunction::sendResponse($json_review);
     // $this->sendResponse($json_review);
 }
예제 #6
0
 public function logoutAction()
 {
     $username = $_POST['username'];
     if (isset($username) != "" and count($_POST) == 1) {
         $this->getAgen($username, "", "logout");
     } else {
         $arrayReturn = array("status" => "failed", "message" => "invalid parameter !", "data" => "");
         $json_agen = $this->_helper->json($arrayReturn);
         Website_P1GlobalFunction::sendResponse($json_agen);
     }
 }
예제 #7
0
 public function getAction()
 {
     $ipAddress = $_POST['ipaddress'];
     $arrayReturn = array();
     if (count($_POST) == 1 and isset($_POST['ipaddress'])) {
         if (isset($ipAddress)) {
             $is_exist = $this->checkVaalidate($ipAddress);
             $json_session = $this->_helper->json($is_exist);
             Website_P1GlobalFunction::sendResponse($json_session);
         } else {
             $arrayReturn['status'] = "failed";
             $arrayReturn['message'] = "ip address cannot empty";
             $rrayReturn['data'] = "";
         }
     } else {
         $arrayReturn['status'] = "failed";
         $arrayReturn['message'] = "Wrong parameter";
         $arrayReturn['data'] = "";
     }
     $json_session = $this->_helper->json($arrayReturn);
     Website_P1GlobalFunction::sendResponse($json_session);
 }