/** * * @param unknown $sender * @param unknown $params */ public function addComments($sender, $params) { $results = $errors = array(); try { Dao::beginTransaction(); if (!isset($params->CallbackParameter->entityName) || ($entityName = trim($params->CallbackParameter->entityName)) === '') { throw new Exception('System Error: EntityName is not provided!'); } if (!isset($params->CallbackParameter->entityId) || ($entityId = trim($params->CallbackParameter->entityId)) === '') { throw new Exception('System Error: entityId is not provided!'); } if (!($entity = $entityName::get($entityId)) instanceof $entityName) { throw new Exception('System Error: no such a entity exisits!'); } if (!isset($params->CallbackParameter->comments) || ($comments = trim($params->CallbackParameter->comments)) === '') { throw new Exception('System Error: invalid comments passed in!'); } $comment = Comments::addComments($entity, $comments, Comments::TYPE_NORMAL); $results['item'] = $comment->getJson(); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $params->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
static function addStudent($inputs) { $student = new Students(); $student->customer_id = $inputs['customerId']; $student->franchisee_id = Session::get('franchiseId'); $student->student_name = $inputs['studentName']; $student->student_gender = $inputs['studentGender']; $student->student_date_of_birth = date('Y-m-d', strtotime($inputs['studentDob'])); $student->nickname = $inputs['nickname']; $student->school = $inputs['school']; $student->location = $inputs['location']; $student->hobbies = $inputs['hobbies']; $student->emergency_contact = $inputs['emergencyContact']; $student->remarks = $inputs['remarks']; $student->health_issue = $inputs['healthIssue']; $student->created_by = Session::get('userId'); $student->created_at = date("Y-m-d H:i:s"); /* echo "<pre>"; print_r($student); echo "</pre>"; */ $student->save(); if ($student) { $commentsInput['customerId'] = $inputs['customerId']; $commentsInput['commentText'] = '(' . $inputs['studentName'] . ') ' . Config::get('constants.KIDS_ADDED'); $commentsInput['commentType'] = 'ACTION_LOG'; //$commentsInput['reminderDate'] = $inputs['reminderTxtBox']; Comments::addComments($commentsInput); } return $student; }
/** * Creating a instance of this * * @param string $name * @param string $description The description of this customer * @param bool $isFromB2B Whether this is imported via B2B * @param int $mageId The id of the customer in Magento * * @return Ambigous <GenericDAO, BaseEntityAbstract> */ public static function create($name, $description = '', $isFromB2B = false, $mageId = 0) { $name = trim($name); $description = trim($description) === '' ? $name : trim($description); $isFromB2B = $isFromB2B === true; $class = __CLASS__; $objects = self::getAllByCriteria('name = ?', array($name), true, 1, 1); if (count($objects) > 0) { $obj = $objects[0]; } else { $obj = new $class(); $obj->setIsFromB2B($isFromB2B); } $obj->setName($name)->setDescription($description)->setMageId($mageId)->save(); $comments = $class . '(ID=' . $obj->getId() . ')' . (count($objects) > 0 ? 'updated' : 'created') . ($isFromB2B === true ? ' via B2B' : '') . ' with (name=' . $name . ', mageId=' . $mageId . ')'; if ($isFromB2B === true) { Comments::addComments($obj, $comments, Comments::TYPE_SYSTEM); } Log::LogEntity($obj, $comments, Log::TYPE_SYSTEM, '', $class . '::' . __FUNCTION__); return $obj; }
/** * Creating a instance of this * * @param string $code * @param string $type * @param bool $required * @param string $scope * @param string $description * @param string $isFromB2B * @param number $mageId * @return ProductAttribute */ public static function create($code, $type, $required, $scope, $description = '', $isFromB2B = false, $mageId = 0, $attributeSetMageId = 0) { $code = trim($code); $type = trim($type); $required = trim($required) === '1' || $required === true || trim($required) === 'true' ? true : false; $scope = trim($scope); $description = trim($description); $isFromB2B = $isFromB2B === true; $class = __CLASS__; $objects = self::getAllByCriteria('code = ?', array($code), true, 1, 1); if (count($objects) > 0) { $obj = $objects[0]; } else { $obj = new $class(); $obj->setIsFromB2B($isFromB2B); } $obj->setCode($code)->setType($type)->setRequired($required)->setScope($scope)->setDescription(trim($description))->setMageId($mageId)->setAttributeSetMageId($attributeSetMageId)->save(); $comments = $class . '(ID=' . $obj->getId() . ')' . (count($objects) > 0 ? 'updated' : 'created') . ($isFromB2B === true ? ' via B2B' : '') . ' with (code=' . $code . ', type="' . $type . '", required="' . $required . '", scope="' . $scope . ', mageId=' . $mageId . ', attributeSetMageId=' . $attributeSetMageId . ')'; if ($isFromB2B === true) { Comments::addComments($obj, $comments, Comments::TYPE_SYSTEM); } Log::LogEntity($obj, $comments, Log::TYPE_SYSTEM, '', $class . '::' . __FUNCTION__); return $obj; }
/** * * @param unknown $sender * @param unknown $params */ public function addComments($sender, $params) { $results = $errors = array(); try { Dao::beginTransaction(); if (!isset($params->CallbackParameter->creditNote) || !($creditNote = CreditNote::get($params->CallbackParameter->creditNote->id)) instanceof CreditNote) { throw new Exception('System Error: invalid CreditNote passed in!'); } if (!isset($params->CallbackParameter->comments) || ($comments = trim($params->CallbackParameter->comments)) === '') { throw new Exception('System Error: invalid comments passed in!'); } $comment = Comments::addComments($creditNote, $comments, Comments::TYPE_NORMAL); $results = $comment->getJson(); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $params->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
/** * Creating a instance of this * * @param string $name * @param string $contactNo * @param string $email * @param Address $billingAddr * @param bool $isFromB2B Whether this is imported via B2B * @param string $description The description of this customer * @param Address $shippingAddr The shiping address * @param int $mageId The id of the customer in Magento * * @return Ambigous <GenericDAO, BaseEntityAbstract> */ public static function create($name, $contactNo, $email, Address $billingAddr = null, $isFromB2B = false, $description = '', Address $shippingAddr = null, $mageId = 0) { $name = trim($name); $contactNo = trim($contactNo); $email = trim($email); $isFromB2B = $isFromB2B === true; $class = __CLASS__; $objects = self::getAllByCriteria('email = ?', array($email), true, 1, 1); if (count($objects) > 0 && $email !== '') { $obj = $objects[0]; } else { $obj = new $class(); $obj->setIsFromB2B($isFromB2B); } $obj->setName($name)->setDescription(trim($description))->setContactNo($contactNo)->setEmail($email)->setBillingAddress($billingAddr)->setShippingAddress($shippingAddr)->setMageId($mageId)->save(); $comments = 'Customer(ID=' . $obj->getId() . ')' . (count($objects) > 0 ? 'updated' : 'created') . ' via B2B with (name=' . $name . ', contactNo=' . $contactNo . ', email=' . $email . ')'; if ($isFromB2B === true) { Comments::addComments($obj, $comments, Comments::TYPE_SYSTEM); } Log::LogEntity($obj, $comments, Log::TYPE_SYSTEM, '', $class . '::' . __FUNCTION__); return $obj; }
/** * Adding the comments for this entity; * * @param string $comments The new comments * @param string $type The type of the comments * @param string $groupId The group identifier for the comments * * @return BaseEntityAbstract */ public function addComment($comments, $type = Comments::TYPE_NORMAL, $groupId = '', &$newComment = null) { if (trim($comments) !== '') { $newComment = Comments::addComments($this, $comments, $type, $groupId); } return $this; }
public function editEnrollment() { $inputs = Input::all(); $paymentreminder_data_make_reminder_null = Comments::where('paymentfollowup_id', '=', $inputs['paymentdue_id'])->update(array('reminder_date' => Null)); $paymentreminder_data = Comments::where('paymentfollowup_id', '=', $inputs['paymentdue_id'])->orderBy('id', 'DESC')->first(); if ($inputs['enrollmentstatus'] == 'REMINDER_CALL') { $commentText = "Reminder call " . 'on ' . date('Y-m-d', strtotime($inputs['reminder-date'])) . ' ' . $inputs['customerCommentTxtarea']; } elseif ($inputs['enrollmentstatus'] == 'FOLLOW_CALL') { $commentText = "Follow call " . 'on ' . date('Y-m-d', strtotime($inputs['reminder-date'])) . ' ' . $inputs['customerCommentTxtarea']; } elseif ($inputs['enrollmentstatus'] == 'CALL_SPOUSE') { $commentText = "Call Spouse " . 'on ' . date('Y-m-d', strtotime($inputs['reminder-date'])) . ' ' . $inputs['customerCommentTxtarea']; } elseif ($inputs['enrollmentstatus'] == 'NOT_AVAILABLE') { $commentText = "Not Available " . 'on ' . date('Y-m-d') . ' ' . $inputs['customerCommentTxtarea']; } elseif ($inputs['enrollmentstatus'] == 'NOT_INTERESTED') { $commentText = "NOT_INTERESTED " . 'on ' . date('Y-m-d') . ' ' . $inputs['customerCommentTxtarea']; } elseif ($inputs['enrollmentstatus'] == 'CLOSE_CALL') { $commentText = "Followupcall closed on " . date('Y-m-d') . ' ' . $inputs['customerCommentTxtarea']; } $commentsInput['customerId'] = $paymentreminder_data['customer_id']; $commentsInput['student_id'] = $paymentreminder_data['student_id']; $commentsInput['paymentfollowup_id'] = $paymentreminder_data['paymentfollowup_id']; $commentsInput['followupType'] = $paymentreminder_data['followup_type']; $commentsInput['commentStatus'] = $inputs['enrollmentstatus']; $commentsInput['commentType'] = $inputs['enrollmenteditAction']; $commentsInput['commentText'] = $commentText; if ($inputs['enrollmentstatus'] != 'CLOSE_CALL') { if ($inputs['enrollmentstatus'] != 'NOT_INTERESTED') { if (isset($inputs['reminder-date'])) { $commentsInput['reminderDate'] = $inputs['reminder-date']; } } } //return Response::json(array('status'=>$inputs)); Comments::addComments($commentsInput); return Response::json(array('status' => 'success')); }
/** * * @param unknown $sender * @param unknown $params * @throws Exception */ public function addPayment($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); if (!isset($param->CallbackParameter->againstEntity) || !isset($param->CallbackParameter->againstEntity->entity) || !isset($param->CallbackParameter->againstEntity->entityId) || ($entityName = trim($param->CallbackParameter->againstEntity->entity)) === '' || !($entity = $entityName::get(trim($param->CallbackParameter->againstEntity->entityId))) instanceof $entityName) { throw new Exception('System Error: invalid Order or CreditNote provided. Can NOT get any payments at all.'); } if (!$entity instanceof Order && !$entity instanceof CreditNote) { throw new Exception('System Error: you can ONLY add payments for a Order or a CreditNote'); } if (!isset($param->CallbackParameter->payment) || !isset($param->CallbackParameter->payment->paidAmount) || ($paidAmount = StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->payment->paidAmount))) === '' || !is_numeric($paidAmount)) { throw new Exception('System Error: invalid Paid Amount passed in!'); } if (!isset($param->CallbackParameter->payment->payment_method_id) || ($paymentMethodId = trim($param->CallbackParameter->payment->payment_method_id)) === '' || !($paymentMethod = PaymentMethod::get($paymentMethodId)) instanceof PaymentMethod) { throw new Exception('System Error: invalid Payment Method passed in!'); } $notifyCust = isset($param->CallbackParameter->payment->notifyCust) && intval($param->CallbackParameter->payment->notifyCust) === 1 ? true : false; $extraComment = ''; if (!isset($param->CallbackParameter->payment->extraComments) || ($extraComment = trim($param->CallbackParameter->payment->extraComments)) === '') { throw new Exception('Some comments for this payment is required.'); } //save the payment $newPayment = null; $entity = $entity->addPayment($paymentMethod, $paidAmount, $extraComment, new UDate(), $newPayment); $results['item'] = $newPayment->getJson(); //notify the customer if ($entity instanceof Order && $notifyCust === true && $entity->getIsFromB2B() === true) { $notificationMsg = trim(OrderNotificationTemplateControl::getMessage('paid', $entity)); if ($notificationMsg !== '') { B2BConnector::getConnector(B2BConnector::CONNECTOR_TYPE_ORDER, SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_WSDL), SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_USER), SystemSettings::getSettings(SystemSettings::TYPE_B2B_SOAP_KEY))->changeOrderStatus($entity, OrderStatus::get(OrderStatus::ID_PICKED)->getMageStatus(), $notificationMsg, true); $comments = 'An email notification contains payment checked info has been sent to customer for: ' . $entity->getStatus()->getName(); Comments::addComments($entity, $comments, Comments::TYPE_SYSTEM); } } Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
Route::any('getEventById', "EventsController@getEventById"); Route::any('saveEvent', "EventsController@saveEvent"); Route::any('saveSchedule', function () { $input = Input::all(); if ($input['studentId'] != "") { $studentSchedule = StudentSchedule::addSchedule($input); if ($studentSchedule) { $status = array("status" => "success"); } } header('Access-Control-Allow-Origin: *'); return Response::json($status); }); Route::any('savecomment', function () { $inputs = Input::all(); $comments = Comments::addComments($inputs); header('Access-Control-Allow-Origin: *'); if ($comments) { return Response::json(array("status" => "success")); } else { return Response::json(array("status" => "failed")); } }); Route::any('customerStudentSearch', function () { $inputs = Input::all(); $term = $inputs['term']; $franchiseeId = Session::get('franchiseId'); $result = DB::select('call sp_searchStudentCustomers(?, ?, ?)', array($term, $franchiseeId, '@result')); if (isset($result)) { return Response::json($result); }
public function addIntroVisit() { $inputs = Input::all(); $schedule['batchId'] = $inputs['introbatchCbx']; $schedule['scheduleDate'] = date('Y-m-d', strtotime($inputs['introVisitTxtBox'])); $schedule['scheduleType'] = 'introvisit'; $schedule['customerId'] = $inputs['customerId']; $schedule['studentId'] = $inputs['studentIdIntroVisit']; $introVisitAdd = BatchSchedule::addIntrovisit($schedule); $commentsInput['customerId'] = $inputs['customerId']; $commentsInput['commentText'] = $inputs['customerCommentTxtarea']; $commentsInput['reminder_type'] = "iv_scheduled"; $commentsInput['reminderDate'] = date("Y-m-d", strtotime($inputs['introVisitTxtBox'])); $comments = Comments::addComments($commentsInput); $customerObject = Customers::where("id", "=", $inputs['customerId'])->get(); $customer['customerName'] = $customerObject['0']->customer_name; $customer['customerEmail'] = $customerObject['0']->customer_email; $customer['introVisitDate'] = date('d M Y', strtotime($inputs['introVisitTxtBox'])); Mail::send('emails.account.introvisit', $customer, function ($msg) use($customer) { $msg->from(Config::get('constants.EMAIL_ID'), Config::get('constants.EMAIL_NAME')); $msg->to($customer['customerEmail'], $customer['customerName'])->subject('The Little Gym - Introductory Visit'); }); if ($introVisitAdd) { return Response::json(array("status" => "success")); } return Response::json(array("status" => "failed")); }