示例#1
0
 public function change_template()
 {
     App::import('Model', 'Service');
     $mService = new Service();
     $service = $mService->find('first', array('conditions' => array('Service.id' => $this->request->data['idService'])));
     echo json_encode($service['Service']);
     die;
 }
 public function createModel()
 {
     $model = new Service();
     $criteria = new CDbCriteria();
     $criteria->select = new CDbExpression('MAX(sort) as sort');
     $max = $model->find($criteria);
     $model->sort = $max->sort + 10;
     return $model;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($encadrantId = null, $serviceId = null)
 {
     if (is_null($serviceId)) {
         return Encadrant_Service_Etudiant::join('Service', 'Service.id_Service', '=', 'Encadrant_Service_Etudiant.id_Stage')->select('Service.*')->where('Encadrant_Service_Etudiant.id_Enseignant', '=', $encadrantId)->distinct()->get();
     } else {
         $service = Service::find($serviceId);
         return is_null($stage) ? response()->json(['error' => 'stage Note not found'], HttpResponse::HTTP_NOT_FOUND) : $service;
     }
 }
示例#4
0
 /**
  * Infos pop-up clic marqueur bus
  */
 public function getInfos()
 {
     $infoBus = Service::find(Input::get('service'));
     $ligne = $infoBus->ligne;
     $service = $infoBus->service;
     $heure = date('H:i:s');
     $arretSuivant = Horaire::getNextArret($heure, $service);
     return Response::json($arretSuivant);
 }
 public static function edit($id)
 {
     $service = Service::find($id);
     //        $offeredServices = OfferedServices::findByService($id);
     $employees = Employee::all();
     //
     $employeeList = OfferedServicesController::getEmployees($id, $employees);
     View::make('service/edit.html', array('attributes' => $service, 'employeeList' => $employeeList, 'employees' => $employees));
 }
示例#6
0
 /**
  * Creates a relation between a specific Advisor and a specific Location
  *
  * @var array
  */
 public function connectServiceWithLocation($services, $advisor_id, $location_id)
 {
     foreach ($services as $service_id) {
         $advisor = Advisor::find($advisor_id);
         $advisor->services()->attach($service_id);
         $service = Service::find($service_id);
         $service->locationsWithAdvisor()->attach($location_id, ['advisor_id' => $advisor_id]);
     }
     return $services;
 }
示例#7
0
 /**
  * 获取服务信息
  *
  * @return object
  */
 public static function getInfo($id, $key = 'name')
 {
     if (!$id) {
         return '<font color="grey">无此服务</font>';
     }
     $service = Service::find($id);
     if (empty($service)) {
         return '<font color="grey">无此服务</font>';
     }
     return $service->{$key};
 }
示例#8
0
 /**
  * 我的服务转换为html
  *
  * @return string
  */
 public function myserviceToHtml()
 {
     if (!$this->services_id) {
         return '<font color="grey">无</font>';
     }
     $services = Service::find($this->services_id);
     if (empty($services)) {
         return '<font color="grey">无此服务</font>';
     }
     $class = 'badge-default';
     $text = $services->name;
     return "<span class=\"badge {$class}\">{$text}</span>";
 }
示例#9
0
 function addToCart()
 {
     if (!Input::get('option')) {
         return Redirect::to('order');
     }
     if (!Input::get('cycle')) {
         return Redirect::to('order');
     }
     $option = ServiceOption::find(Input::get('option'));
     $service = Service::find($option->service_id);
     $cycle = BillingCycle::find(Input::get('cycle'));
     Cart::insert(array('id' => $option->id, 'name' => $service->name . ' ' . $option->option_name, 'price' => $option->base_price, 'quantity' => $cycle->cycle));
     return Redirect::to('order');
 }
 public static function sandbox()
 {
     $service = Service::find(1);
     $services = Service::all();
     $employees = Employee::all();
     $employee = Employee::find(1);
     $service2 = new Service(array('name' => 'aasdd', 'price' => "2", 'description' => "asfafaf"));
     $errors = $service2->errors();
     Kint::dump($employee);
     Kint::dump($employees);
     Kint::dump($service);
     Kint::dump($services);
     Kint::dump($errors);
     //        View::make('helloworld.html');
 }
 private function update($tabla)
 {
     switch ($tabla) {
         case 'Service':
             $service = Service::update($service_id, array('driver_id' => $driver_id, 'status_id' => "2", 'car_id' => $driver_tmp->car_id));
             $this->servicio = Service::find($this->servicio_id);
             $this->validar($service);
             break;
         case 'Driver':
             $driver = Driver::update($this->driver_id, array("available" => "0"));
             $this->conductor = Driver::find($this->conductor_id);
             $this->validar($driver);
             break;
     }
 }
示例#12
0
 /**
  * [saveModel - saves ou model info to the DB]
  * @param  boolean $service [description]
  * @return [Eloquent model] [service eloquent model]
  */
 protected function saveModel($service = false)
 {
     if (Input::get('id')) {
         $service = Service::find(Input::get('id'));
     }
     if (!$service) {
         $service = new Service();
     }
     $load_company_model = $service->companies;
     $service->name = Input::get('name');
     $service->category_id = Input::get('category_id');
     $service->status_id = Input::get('status_id');
     $service->invoice_periods_id = Input::get('invoice_periods_id');
     $service->default_monthly_costs = Input::get('default_monthly_costs');
     $service->comment = Input::get('comment');
     $service->save();
     return $service;
 }
 public function delete()
 {
     if (Request::ajax()) {
         $data['response'] = 'error';
         $data['content'] = "Item cannot be deleted.";
         $id = Input::get('service_id');
         $package = Package::where('service_id', '=', $id)->count();
         if ($package == 0) {
             $service = Service::find($id);
             $service->delete();
             $data['response'] = 'ok';
             $data['content'] = "Item was successfully deleted.";
         }
         $response = Response::make(json_encode($data), 200);
         $response->header('Content-Type', 'text/json');
         return $response;
     }
 }
 /**
  *
  */
 public function generalAction()
 {
     $dataRequest = $this->request->getJsonPost();
     $fields = array("key", "platform");
     if ($this->_checkFields($dataRequest, $fields)) {
         if ($this->_validKey()) {
             $services = Service::find();
             $return = array();
             $categories = array();
             foreach ($services as $item) {
                 $categories = array();
                 foreach ($item->ServiceCategory as $item2) {
                     $categories[] = array("id" => $item->getId(), "name" => utf8_encode($item2->getName()), "description" => utf8_encode($item2->getDescription()), "image" => $item2->getImage(), "video" => $item2->getVideo());
                 }
                 $return[] = array("id" => $item->getId(), "name" => utf8_encode($item->getName()), "description" => utf8_encode($item->getDescription()), "image" => $item->getImage(), "categories" => $categories);
             }
             $this->setJsonResponse(ControllerBase::SUCCESS, ControllerBase::FAILED_MESSAGE, array("status" => $this->strings->getString("http", "success"), "message" => $this->strings->getString("platform", "success"), "data" => $return));
         }
     }
 }
示例#15
0
 public function getTimeSlot($service_id)
 {
     Activity::log(['contentId' => $service_id, 'contentType' => 'Outlet', 'action' => 'getTimeSlot', 'description' => 'getTimeSlot of Service', 'details' => 'Service Id: ' . $service_id, 'updated' => false]);
     $service = Service::find($service_id);
     $outlet = Outlet::find($service->outlet_id);
     $startTime = explode(':', $outlet->startTime);
     $endTime = explode(':', $outlet->endTime);
     if (count($startTime) < 2 || count($endTime) < 2) {
         return array();
     }
     $start = mktime($startTime[0], $startTime[1], 0, 8, 12, 2014);
     $end = mktime($endTime[0], $endTime[1], 0, 8, 12, 2014);
     $hourArray = array();
     $count = 1;
     $hourArray[] = $start;
     while ($start < $end && $count < 1000) {
         $date = $start + $service->time_operate * 60;
         $hourArray[] = $date;
         $start = $date;
         $count++;
     }
     return $hourArray;
 }
 public function create($signup_id = null)
 {
     $signup = self::load_signup($signup_id);
     $event_service = new EventService();
     $event_service->event_signup_id = $signup->id;
     if ($this->post) {
         $event_id = mysql_real_escape_string($signup->event->id);
         $service_id = mysql_real_escape_string($_POST['service']);
         $service = Service::find("services.id = '{$service_id}' AND services.event_id = '{$event_id}'");
         if ($service) {
             if ($service->participant and !$signup->event_ticket->participant) {
                 $event_service->add_error("You cannot add participant services to this booking");
             }
             $event_service->service_id = $service->id;
             $event_service->note = $_POST['note'];
             $event_service->paid = $_POST['paid'];
             if ($event_service->save()) {
                 Site::Flash("notice", "The service booking has been added");
                 Redirect("admin/signups/{$signup->id}");
             }
         }
     }
     $available_services = $signup->available_services(false, true);
     if (count($available_services) == 0) {
         Site::flash("error", "There are no services available for this signup");
         Redirect("admin/signups/{$signup->id}");
     }
     $services = array();
     foreach ($available_services as $service) {
         $services[$service->id] = $service->name;
     }
     $this->assign("services", $services);
     $this->assign("signup", $signup);
     $this->assign("service", $event_service);
     $this->title = "Signup {$signup->id} Services";
     $this->render("event_service/create.tpl");
 }
 /**
  * [invoiceClient - append selected entries to a MB invoice if one exists. Otherwise create a new one]
  * @param  [array]  $all_company_values     [segmented data company row]
  * @param  [int]    $company_id             [description]
  * @param  [string] $op_type                [invoice/invoice_clear + strip/strip_clear]
  * @return [mb invoice]                     [MB invoice that was used]
  */
 public function invoiceClient($all_company_values, $company_id, $op_type)
 {
     error_log('Invoicing client');
     // create invoice details obj
     //$customer_id = Config::get('eenvoudcrm.moneybird_test_user_id');
     $customer_id = $this->getContact($company_id);
     if ($customer_id === -1) {
         return false;
     }
     error_log('Local Contact Exists');
     $contact = null;
     try {
         $contact = $this->getRequest('contacts/' . $customer_id . '.json');
     } catch (Exception $e) {
         error_log($e->getMessage());
         die;
     }
     if (!$contact) {
         error_log("Consistency check failure: contact not found");
         return false;
     }
     error_log('Remote Contact Exists');
     // check for open invoices
     try {
         $open_invoices = $this->getRequest('sales_invoices.json?filter=state:draft,contact_id:' . $customer_id);
     } catch (Exception $e) {
         error_log($e->getMessage());
         die;
     }
     //$invoice = null;
     $details = [];
     $new_invoice = false;
     if (count($open_invoices) > 0) {
         $used_invoice_id = -1;
         error_log('found an open invoice for ' . $customer_id . ' - ' . json_encode($open_invoices[0]));
         //$used_invoice_id = 135871568029943606;
         if (isset($open_invoices[0]->id)) {
             $used_invoice_id = $open_invoices[0]->id;
         }
         if ($used_invoice_id === -1) {
             $error_msg = 'Error: IntegrationMoneybirdController2 - Found open invoices but could not get invoice id';
             throw new Exception($error_msg);
             error_log($error_msg);
             die;
         }
         // sanity check - try getting the first invoice draft
         // try {
         //     $invoice = $this->getRequest('sales_invoices/'.$used_invoice_id.'.json');
         // } catch(Exception $e) {
         //     error_log($e->getMessage());
         //     die();
         // }
     } else {
         $new_invoice = true;
     }
     // get price and description
     if ($op_type === 'subscription') {
         // append details
         $segmented_by_service = $this->segmentDataByService($all_company_values);
         foreach ($segmented_by_service as $service_ndx => $service_values) {
             $service = Service::find((int) $service_ndx);
             // load relations
             $load_cat_relation = $service->category;
             $service_line = "\r\n*" . $service->category->name . " - " . $service->name . "*";
             // invoice details line 1
             foreach ($service_values as $key => $company_row_values) {
                 $curr_price = 0;
                 $curr_description = '';
                 $item_id = (int) $company_row_values['subscriptions.id'];
                 $subscription = Subscription::find($item_id);
                 $service = $subscription->service;
                 $service_category = $service->category;
                 $periodicity = $subscription->invoice_periods_id;
                 $interval_size = 1;
                 $periodicity_str = "";
                 switch ($periodicity) {
                     case 1:
                         $periodicity_str = "jaar";
                         $interval_size = 12;
                         break;
                     case 2:
                         $periodicity_str = "kwartjaar";
                         $interval_size = 4;
                         break;
                     case 3:
                         $periodicity_str = "kwartaal";
                         $interval_size = 3;
                         break;
                     case 4:
                         $periodicity_str = "mnd";
                         $interval_size = 1;
                         break;
                     default:
                         break;
                 }
                 // avoid MB errors dues to ammount too large
                 if ($subscription->subscription_start === '0000-00-00' || $subscription->subscription_end === '000-00-00') {
                     continue;
                 }
                 $start_date = new DateTime($subscription->subscription_start);
                 $end_date = new DateTime($subscription->subscription_end);
                 $end_date->add(new DateInterval('P1D'));
                 $num_months = $start_date->diff($end_date)->m + $start_date->diff($end_date)->y * 12;
                 $num_items = floatval($num_months) / floatval($interval_size);
                 if ($interval_size > $num_months) {
                     $num_items = $num_months;
                     $periodicity_str = "maand";
                 }
                 // calc price depending on whether item is singular or periodic
                 $curr_price = round((double) $subscription->price, 2);
                 $curr_description = ($subscription->description ? "{$subscription->description}" : "") . " _({$subscription->subscription_start} - {$subscription->subscription_end})_";
                 // invoice details line 1
                 $details[] = (object) ['amount' => "{$num_items} x {$periodicity_str}", 'description' => $curr_description, 'price' => $curr_price, 'tax_rate_id' => Config::get('eenvoudcrm.taxrate_high_id'), 'ledger_account_id' => Config::get('eenvoudcrm.ledger_account_id')];
             }
         }
     } elseif ($op_type === 'worklog') {
         $worklogs_line = "\r\n*Werklogs*";
         // invoice details line 1
         $details[] = (object) ['description' => $worklogs_line];
         foreach ($all_company_values as $company_row_ndx => $company_row_values) {
             $curr_price = 0;
             $curr_description = '';
             $item_id = (int) $company_row_values['worklogs.id'];
             $worklog = Werklog::find($item_id);
             // round minutes to upper quarter of the hour
             $round_minutes = floor($worklog->minutes / 15.0) * 15 + ($worklog->minutes % 15 > 0 ? 15 : 0);
             $dec_hours = (double) $round_minutes / 60.0;
             // calc total price
             $curr_price = (double) Config::get('eenvoudcrm.worklog_price_per_hour') * $dec_hours;
             $hours = floor($dec_hours);
             $minutes = round(60.0 * ($dec_hours - $hours));
             $curr_description = "{$worklog->date} - (" . ($hours > 0 ? "{$hours} h " : "") . "{$minutes} m)" . ($worklog->description ? " - {$worklog->description}" : "");
             if ($worklog->comment) {
                 $curr_description .= "\r\n[{$worklog->comment}]";
             }
             // invoice details line 1
             $details[] = (object) ['amount' => '1 x', 'description' => $curr_description, 'price' => $curr_price, 'tax_rate_id' => Config::get('eenvoudcrm.taxrate_high_id'), 'ledger_account_id' => Config::get('eenvoudcrm.ledger_account_id')];
         }
     }
     $details_line = '{"sales_invoice":{"details_attributes":' . json_encode((object) $details) . '}}';
     $ret_invoice = null;
     // save
     try {
         if (!$new_invoice) {
             $ret_invoice = $this->patchRequest('sales_invoices/' . $used_invoice_id . '.json', $details_line);
         } else {
             $invoice = '{"sales_invoice":{"reference":"","contact_id":' . $customer_id . ',"details_attributes":' . json_encode((object) $details) . '}}';
             $ret_invoice = $this->postRequest('sales_invoices.json', $invoice);
         }
     } catch (Exception $e) {
         error_log($e->getMessage());
         die;
     }
     return $ret_invoice;
 }
 protected static function load_service($event, $id = null)
 {
     if (!$id) {
         $id = $_GET['id'];
     }
     $id = mysql_real_escape_string($id);
     $event_id = mysql_real_escape_string($event->id);
     $service = Service::find("services.event_id = '{$event_id}' AND services.id = '{$id}'");
     if ($service) {
         return $service;
     } else {
         Error404();
     }
 }
示例#19
0
 public static function enable($id)
 {
     $service = Service::find($id, false);
     if ($service) {
         $service->enable();
         Redirect::to(\Slim\Slim::getInstance()->urlFor('services_index'), array('message' => 'Palvelu otettu käyttöön!'));
     } else {
         Redirect::to(\Slim\Slim::getInstance()->urlFor('services_index'), array('message' => 'Palvelua ei löydy!', 'error' => true));
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Service::find($id)->delete();
     return Redirect::to('services')->with('success', 'Service deleted successfully');
 }
示例#21
0
 /**
  * 我的服务转换为html
  *
  * @return string
  */
 public function serviceToHtml()
 {
     if (!$this->service_type_id) {
         return '<font color="grey">无</font>';
     }
     // return $this->services_type_id;exit;
     $services = Service::find($this->service_type_id);
     // print_r($services->name);exit;
     if (empty($services)) {
         return '<font color="grey">无此服务</font>';
     }
     $class = 'badge-default';
     $text = $services->name;
     return "<span class=\"badge {$class}\">{$text}</span>";
 }
示例#22
0
 public function updateEndpoint()
 {
     $success = true;
     $message = "Successfully added service";
     $data = Input::get();
     $endpoint = new EndPoint();
     $service = Service::find($data['serviceId']);
     if ($data['id'] != -1) {
         $endpoint = EndPoint::find($data['id']);
         $message = "Successfully updated service";
     }
     $endpoint->service_id = $data['serviceId'];
     $endpoint->name = $data['name'];
     $endpoint->httpMethod = $data['httpMethods'];
     $endpoint->httpHeaders = $data['httpHeaders'];
     $endpoint->httpContentType = $data['httpContentType'];
     $endpoint->save();
     $endpoint = $service->endpoints()->save($endpoint);
     $computedEndpoint = static::GetComputedEndpoint($endpoint);
     return Response::json(array("success" => $success, "message" => $message, "endpoint" => $computedEndpoint));
 }
示例#23
0
 public function postBook()
 {
     $response = null;
     $Bill = null;
     $spa_id = Input::get('spaName');
     $outlet_id = Input::get('spaLocation');
     $service_id = Input::get('serviceName');
     $apptDate = Input::get('apptDate');
     $apptTime = Input::get('timeSlot');
     if (!empty($spa_id) && !empty($outlet_id) && !empty($service_id) && !empty($apptDate)) {
         $apptDateTime = strtotime($apptDate . " " . $apptTime);
         $service = Service::find($service_id);
         $response = array("retailerName" => Retailer::find($spa_id)->name, "outletName" => Outlet::find($outlet_id)->name, "serviceName" => $service->name . " (" . $service->time_operate . " mins)", "apptDateTime" => $apptDateTime, "price" => $service->price);
         if (!Auth::user()) {
             return View::make('site/user/book', compact('response', 'Bill'));
         }
         $deal = Deal::where('service_id', '=', $service_id)->where('deal_type', '=', 'Service')->first();
         if ($deal == null) {
             $deal = new Deal();
             $deal->service_id = $service_id;
             $deal->deal_type = 'Service';
             $deal->title = $service->name;
             $deal->amount = $service->price;
             $deal->discount = 0;
             $deal->special_request = "";
             $deal->status = "active";
             $deal->save();
         }
         $Bill = new DealTransaction();
         $Bill->deal_id = $deal->id;
         $Bill->consumer_id = Auth::user()->id;
         $Bill->consumer_email = Auth::user()->email;
         $Bill->qty = 1;
         $Bill->amount = $service->price;
         $Bill->total = $service->price;
         $Bill->save();
         return View::make('site/user/book', compact('response', 'Bill'));
     }
     return Redirect::to('/');
 }
示例#24
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $service = Service::find($id);
     $service->delete();
 }
 /**
  * edit method
  *
  * @throws NotFoundException
  * @param string $id
  * @return void
  */
 public function edit($id = null)
 {
     if (!$this->Image->exists($id)) {
         throw new NotFoundException(__('Invalid image'));
     }
     if ($this->request->is(array('post', 'put'))) {
         if ($this->Image->save($this->request->data)) {
             $this->Session->setFlash(__('The image has been saved.'));
             return $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The image could not be saved. Please, try again.'));
         }
     } else {
         $options = array('conditions' => array('Image.' . $this->Image->primaryKey => $id));
         $this->request->data = $this->Image->find('first', $options);
     }
     $serviceModel = new Service();
     $servicios = $serviceModel->find('list', array('fields' => array('id', 'name')));
     $this->set('servicios', $servicios);
 }
示例#26
0
 public function applyForServiceAction()
 {
     $user = $this->getAuth();
     $cars = Car::find(array('conditions' => 'owner = ?1', 'bind' => array(1 => $user['user_id'])));
     $full_dates = "";
     $date = new DateTime("now");
     $day = new DateInterval("P1D");
     for ($i = 0; $i < 21; $i++) {
         $apps = Application::find(array('conditions' => 'term >= ?1 AND term <= ?2', 'bind' => array(1 => $date->format('Y.m.d') . ' 00:00', 2 => $date->format('Y.m.d') . ' 24:00')));
         if (count($apps) >= 4 * 20) {
             $full_dates .= "'" . $date->format('m.d.Y') . "', ";
         }
         $date->add($day);
     }
     $services = Service::find();
     $this->view->setParamToView('cars', $cars);
     $this->view->setParamToView('dates', $full_dates);
     $this->view->setParamToView('services', $services);
 }
示例#27
0
 public function getServices()
 {
     $service = Service::find();
     return $service;
 }