Esempio n. 1
0
 /**
  * Retrive the package stock
  *
  * @param $number customer number
  * @return object
  */
 public function find($number)
 {
     $resources = new Resources();
     $resources->setHeaders(array('Accept' => 'application/json'));
     $resources->setBaseUrl(Config::get("resources::gemba.baseUrl"));
     $json = $resources->get("packagesstock.{$number}");
     $stock = json_decode($json);
     if ($stock->status > 0) {
         return array();
     }
     return $stock->data->PackageStock;
 }
Esempio n. 2
0
 /**
  * Get all packages
  * @return array of packages
  */
 public function all()
 {
     $resources = new Resources();
     $resources->setAuthorization();
     $resources->setBaseUrl(Config::get("resources::gemba.baseUrl"));
     $resources->setHeaders(array("Accept" => "application/json"));
     $json = $resources->get("packagesrequest");
     $packagesRequest = json_decode($json, true);
     if (empty($packagesRequest)) {
         return array();
     }
     $listPackages = array();
     return $packagesRequest;
 }
Esempio n. 3
0
 /**
  * Get all packages
  * @return array of packages
  */
 public function all()
 {
     $resources = new Resources();
     $resources->setAuthorization();
     $resources->setBaseUrl("http://backoffice.my.alfaloc.pt");
     $json = $resources->get("packagesrequest");
     $budgets = json_decode($json, true);
     if (empty($budgets)) {
         return array();
     }
     $listBudgets = array();
     foreach ($budgets as $budget) {
         $c = new Budget();
         $c->fill($budget);
         if ($c->customerNumber == Session::get("my_account_selected")) {
             $listBudgets[] = $c->toArray();
         }
     }
     return $listBudgets;
 }
Esempio n. 4
0
 /**
  * Retrive the service
  *
  * @param $id
  * @return object
  */
 public function find($id)
 {
     $resources = new Resources();
     $resources->setAuthorization();
     $json = $resources->get("service.{$id}");
     $service = json_decode($json);
     if (empty($service)) {
         return null;
     }
     $this->id = $service->id;
     $this->id_transport = $service->id_transport;
     $this->name = $service->name;
     $this->days_number = $service->days_number;
     $this->coefficient = $service->coefficient;
     $this->vat = $service->vat;
     $this->cc_document = $service->cc_document;
     $this->vd_document = $service->vd_document;
     $this->myalfaloc = $service->myalfaloc;
     $this->special = $service->special;
     $this->service_transport = $service->service_transport;
     return $this;
 }
Esempio n. 5
0
 /**
  * Get user
  * @param user number
  * @return bool
  */
 private function retrive($number)
 {
     $resources = new Resources();
     $resources->setAuthorization();
     $resources->setHeaders(array('Accept' => 'application/json'));
     $json = $resources->get("users.{$number}");
     $user = json_decode($json, true);
     if (!$user || count($user) == 0) {
         return false;
     }
     $this->fill($user);
     return true;
 }
Esempio n. 6
0
 /**
  * Retrive the budget pdf
  *
  * @param $id
  * @return object
  */
 public function pdf($id)
 {
     $resources = new Resources();
     $resources->setAuthorization();
     $pdf = $resources->get("budget.{$id}.pdf");
     return $pdf;
 }
Esempio n. 7
0
 /**
  * Retrive the specific fares.
  * The fares must be array or string.
  * if is a string the fares must be seperated by comma.
  * @param mixed $fares
  * @return array of fares
  */
 public function search($fares)
 {
     $f = is_array($fares) ? implode(",", $fares) : $fares;
     $resources = new Resources();
     $resources->setAuthorization();
     $json = $resources->get("fare.filter?fares={$f}");
     $fare = json_decode($json);
     if (empty($fare)) {
         return null;
     }
     $listFares = array();
     foreach ($fare as $item) {
         $f = $this->fill($item);
         $listFares[] = $f->toArray();
     }
     return $listFares;
 }
Esempio n. 8
0
 /**
  * Get customer
  * @param customer number
  * @return bool
  */
 private function retrive($number)
 {
     $resources = new Resources();
     $resources->setHeaders(array('Accept' => 'application/json'));
     $json = $resources->get("customer.{$number}");
     $customer = json_decode($json);
     if ($customer->status > 0) {
         return false;
     }
     $this->number = $customer->data->customer[0][0]->Cliente;
     $this->password = $customer->data->customer[0][0]->CDU_Password;
     $this->name = $customer->data->customer[0][0]->Nome;
     $this->address = $customer->data->customer[0][0]->Fac_Mor;
     $this->local = $customer->data->customer[0][0]->Fac_Local;
     $this->zipCode = $customer->data->customer[0][0]->Fac_Cp;
     $this->city = $customer->data->customer[0][0]->Fac_Cploc;
     $this->phone = $customer->data->customer[0][0]->Fac_Tel;
     $this->fax = $customer->data->customer[0][0]->Fac_Fax;
     $this->country = $customer->data->customer[0][0]->Pais;
     $this->fiscalNumber = $customer->data->customer[0][0]->NumContrib;
     $this->creditStatus = $customer->data->customer[0][0]->CDU_CampoVar1;
     $this->fares = $customer->data->customer[0][0]->CDU_CampoVar2;
     $this->contactCycle = $customer->data->customer[0][0]->CDU_CampoVar4;
     $this->cutOff = $customer->data->customer[0][0]->CDU_ObsOps;
     $this->seller = $customer->data->customer[0][0]->Vendedor;
     $this->delegation = $customer->data->customer[0][0]->Delegacao;
     $this->creationDate = $customer->data->customer[0][0]->DataCriacao;
     $this->updateDate = $customer->data->customer[0][0]->DataUltimaActualizacao;
     return true;
 }
Esempio n. 9
0
 /**
  * Get 
  * @param customer number
  * @return bool
  */
 private function retrive($number)
 {
     $resources = new Resources();
     $resources->setHeaders(array('Accept' => 'application/json', 'Authorization' => 'Basic bG9nbWU6MTIzbG9nbWUwOTg='));
     $json = $resources->get("country.{$number}");
     $country = json_decode($json);
     if (!$country) {
         return false;
     }
     $this->id = $country->Id;
     $this->code = $country->Code;
     $this->alpha2 = $country->Alpha2;
     $this->alpha3 = $country->Alpha3;
     $this->name_en = $country->Name_en;
     $this->name_pt = $country->Name_pt;
     $this->transports = $country->transports;
     return true;
 }