Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 /**
  * Retrive all countries
  * 
  * @return array of object
  */
 public function all()
 {
     $resources = new Resources();
     $resources->setAuthorization();
     $json = $resources->get("country");
     $countries = json_decode($json);
     if (empty($countries)) {
         return array();
     }
     $listCountries = array();
     foreach ($countries as $country) {
         $c = new stdClass();
         $c->id = $country->Id;
         $c->code = $country->Code;
         $c->alpha2 = $country->Alpha2;
         $c->alpha3 = $country->Alpha3;
         $c->name_en = $country->Name_en;
         $c->name_pt = $country->Name_pt;
         $listCountries[] = $c;
     }
     return $listCountries;
 }
Ejemplo 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;
 }
Ejemplo 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;
 }
Ejemplo 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;
 }
Ejemplo 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;
 }