예제 #1
0
 public function actionIndex()
 {
     $op = EnvUtil::getRequest("op");
     $op = in_array($op, array("dept", "letter")) ? $op : "dept";
     $params = array();
     if ($op == "letter") {
         $params["datas"] = $this->getDataByLetter();
     } else {
         $params["datas"] = $this->getDataByDept();
     }
     $userDatas = array();
     if (!empty($params["datas"])) {
         foreach ($params["datas"] as $datas) {
             $userDatas = $op == "dept" ? array_merge($userDatas, $datas["users"]) : array_merge($userDatas, $datas);
         }
     }
     $params["uids"] = implode(",", ConvertUtil::getSubByKey($userDatas, "uid"));
     $uid = Ibos::app()->user->uid;
     $params["cuids"] = Contact::model()->fetchAllConstantByUid($uid);
     $this->setPageTitle(Ibos::lang("Contact"));
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Contact"), "url" => $this->createUrl("defalut/index")), array("name" => Ibos::lang("Company contact"))));
     $view = $op == "letter" ? "letter" : "dept";
     $params["allLetters"] = $this->allLetters;
     $this->render($view, $params);
 }
예제 #2
0
 public function actionIndex()
 {
     $criteriaContact = new CDbCriteria();
     $criteriaContact->limit = 10;
     $criteriaContact->order = "id DESC";
     $contact = Contact::model()->findAll($criteriaContact);
     $this->render('index', compact('contact'));
 }
예제 #3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Contact the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Contact::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #4
0
파일: Contact.php 프로젝트: jayrulez/yiisns
 public function delete()
 {
     $status = parent::delete();
     $inversed = Contact::model()->findByAttributes(array('user_id' => $this->contact_id, 'contact_id' => $this->user_id));
     if ($inversed !== null) {
         $inversed->delete();
     }
     return $status;
 }
 public function init()
 {
     $eventHandler = array($this, 'deletePersonsOrAccountsItems');
     Contact::model()->attachEventHandler('onAfterDelete', $eventHandler);
     $this->attachedEventHandlersIndexedByModelClassName['Contact'] = array('onAfterDelete', $eventHandler);
     User::model()->attachEventHandler('onAfterDelete', $eventHandler);
     $this->attachedEventHandlersIndexedByModelClassName['User'] = array('onAfterDelete', $eventHandler);
     Account::model()->attachEventHandler('onAfterDelete', $eventHandler);
     $this->attachedEventHandlersIndexedByModelClassName['Account'] = array('onAfterDelete', $eventHandler);
 }
 /**
  * Collate the data and persist it to the table.
  *
  * @param $id
  *
  * @throws CHttpException
  * @throws Exception
  */
 public function loadData($id)
 {
     $booking = Element_OphTrOperationbooking_Operation::model()->find('event_id=?', array($id));
     $eye = Eye::model()->findByPk($booking->eye_id);
     if ($eye->name === 'Both') {
         throw new CHttpException(400, 'Can\'t display whiteboard for dual eye bookings');
     }
     $eyeLabel = strtolower($eye->name);
     $event = Event::model()->findByPk($id);
     $episode = Episode::model()->findByPk($event->episode_id);
     $patient = Patient::model()->findByPk($episode->patient_id);
     $contact = Contact::model()->findByPk($patient->contact_id);
     $biometryCriteria = new CDbCriteria();
     $biometryCriteria->addCondition('patient_id = :patient_id');
     $biometryCriteria->params = array('patient_id' => $patient->id);
     $biometryCriteria->order = 'last_modified_date DESC';
     $biometryCriteria->limit = 1;
     $biometry = Element_OphTrOperationnote_Biometry::model()->find($biometryCriteria);
     $examination = $event->getPreviousInEpisode(EventType::model()->findByAttributes(array('name' => 'Examination'))->id);
     //$management = new \OEModule\OphCiExamination\models\Element_OphCiExamination_Management();
     //$anterior = new \OEModule\OphCiExamination\models\Element_OphCiExamination_AnteriorSegment();
     $risks = new \OEModule\OphCiExamination\models\Element_OphCiExamination_HistoryRisk();
     if ($examination) {
         //$management = $management->findByAttributes(array('event_id' => $examination->id));
         //$anterior = $anterior->findByAttributes(array('event_id' => $examination->id));
         $risks = $risks->findByAttributes(array('event_id' => $examination->id));
     }
     $labResult = Element_OphInLabResults_Inr::model()->findPatientResultByType($patient->id, '1');
     $allergies = Yii::app()->db->createCommand()->select('a.name as name')->from('patient_allergy_assignment pas')->leftJoin('allergy a', 'pas.allergy_id = a.id')->where("pas.patient_id = {$episode->patient_id}")->order('a.name')->queryAll();
     $allergyString = 'None';
     if ($allergies) {
         $allergyString = implode(',', array_column($allergies, 'name'));
     }
     $operation = Yii::app()->db->createCommand()->select('proc.term as term')->from('et_ophtroperationbooking_operation op')->leftJoin('ophtroperationbooking_operation_procedures_procedures opp', 'opp.element_id = op.id')->leftJoin('proc', 'opp.proc_id = proc.id')->where("op.event_id = {$id}")->queryAll();
     $this->event_id = $id;
     $this->booking = $booking;
     $this->eye_id = $eye->id;
     $this->eye = $eye;
     $this->predicted_additional_equipment = $booking->special_equipment_details;
     $this->comments = '';
     $this->patient_name = $contact['title'] . ' ' . $contact['first_name'] . ' ' . $contact['last_name'];
     $this->date_of_birth = $patient['dob'];
     $this->hos_num = $patient['hos_num'];
     $this->procedure = implode(',', array_column($operation, 'term'));
     $this->allergies = $allergyString;
     $this->iol_model = $biometry ? $biometry->attributes['lens_description_' . $eyeLabel] : 'Unknown';
     $this->iol_power = $biometry ? $biometry->attributes['iol_power_' . $eyeLabel] : 'none';
     $this->predicted_refractive_outcome = $biometry ? $biometry->attributes['predicted_refraction_' . $eyeLabel] : 'Unknown';
     $this->alpha_blockers = $patient->hasRisk('Alpha blockers');
     $this->anticoagulants = $patient->hasRisk('Anticoagulants');
     $this->alpha_blocker_name = $risks ? $risks->alpha_blocker_name : '';
     $this->anticoagulant_name = $risks ? $risks->anticoagulant_name : '';
     $this->inr = $labResult ? $labResult : 'None';
     $this->save();
 }
예제 #7
0
 public function actionDelete()
 {
     $contact = Contact::model()->findByAttributes(array('user_id' => Yii::app()->getUser()->getId(), 'contact_id' => Yii::app()->getRequest()->getParam('id')));
     if ($contact !== null) {
         $userLink = $contact->contact->getUrl();
         $contact->delete();
         $this->redirect($userLink);
     } else {
         throw new CHttpException(404, Yii::t('application', 'Write error message here'));
     }
 }
예제 #8
0
 public function actionGetContentByID($id)
 {
     $arr = explode(",", $id);
     $id = $arr[count($arr) - 1];
     $model = Contact::model()->findByPk($id);
     $data = array();
     $data[0] = $model->content;
     $data[1] = $model->title;
     $data[2] = $model->address;
     echo json_encode($data);
 }
예제 #9
0
 public function beforeDelete()
 {
     $contactgroup = Contact::model()->findAll();
     foreach ($contactgroup as $id => $item) {
         $contactgroups = explode('|', $item->contact_group_id);
         if (in_array($this->contact_group_id, array_values($contactgroups))) {
             Yii::app()->setFlashMessage('Can not delete these, Contact Group, it is used in contact master', 'error');
             return false;
         }
     }
     return parent::beforeDelete();
 }
예제 #10
0
 public function beforeDelete()
 {
     $suppliers = Contact::model()->findAll();
     foreach ($suppliers as $id => $item) {
         $vehicles = explode('|', $item->city_id);
         if (in_array($this->city_id, array_values($vehicles))) {
             Yii::app()->setFlashMessage('Can not delete, City in use in contact master', 'error');
             return false;
         }
     }
     return parent::beforeDelete();
 }
예제 #11
0
 public function actionExportCsv()
 {
     $model = new Contact('search');
     $model->unsetAttributes();
     if (isset($_GET['Contact'])) {
         $model->attributes = $_GET['Contact'];
     }
     if (isset($_SESSION['criteria']) && $_SESSION['criteria'] != null && $_SESSION['criteria'] instanceof EMongoCriteria) {
         $criteria = $_SESSION['criteria'];
     } else {
         $criteria = new EMongoCriteria();
     }
     $models = Contact::model()->findAll($criteria);
     $listAttributes = array();
     foreach ($models as $model) {
         //récuperation de la liste totale des attributs
         foreach ($model->attributes as $attributeName => $attributeValue) {
             $listAttributes[$attributeName] = $attributeName;
         }
     }
     $dataProvider = array();
     //creation du dataprovider
     foreach ($models as $model) {
         $datas = array();
         foreach ($listAttributes as $attribute) {
             if (isset($model->{$attribute})) {
                 if (!is_object($model->{$attribute})) {
                     $datas[$attribute] = $model->{$attribute};
                 }
             } else {
                 $datas[$attribute] = "";
             }
         }
         //create full adress
         $datas['fullAddress'] = $model->fullAddress;
         //create biobank
         $datas['fullAddress'] = $model->biobankName;
         $dataProvider[] = $datas;
     }
     $filename = 'biobanks_list.csv';
     $csv = new ECSVExport($dataProvider);
     $toExclude = array();
     $toExport = $model->attributeExportedLabels();
     foreach ($model->attributes as $attribute => $value) {
         if (!isset($toExport[$attribute])) {
             $toExclude[] = $attribute;
         }
     }
     $csv->setExclude($toExclude);
     // $csv->exportCurrentPageOnly();
     Yii::app()->getRequest()->sendFile($filename, $csv->toCSV(), "text/csv", false);
 }
예제 #12
0
 public function actionIndex()
 {
     $uid = Ibos::app()->user->uid;
     $cuids = Contact::model()->fetchAllConstantByUid($uid);
     $res = UserUtil::getUserByPy($cuids);
     $group = ContactUtil::handleLetterGroup($res);
     $userDatas = array();
     foreach ($group as $users) {
         $userDatas = array_merge($userDatas, $users);
     }
     $params = array("datas" => $group, "letters" => array_keys($group), "allLetters" => $this->allLetters, "uids" => implode(",", ConvertUtil::getSubByKey($userDatas, "uid")));
     $this->setPageTitle(Ibos::lang("Regular contact"));
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Contact"), "url" => $this->createUrl("default/index")), array("name" => Ibos::lang("Regular contact"))));
     $this->render("index", $params);
 }
예제 #13
0
 public function run($args)
 {
     //uppar case for each last name of contact
     $criteria = new EMongoCriteria();
     $criteria->sort('last_name', EMongoCriteria::SORT_ASC);
     $contacts = Contact::model()->findAll($criteria);
     foreach ($contacts as $model) {
         $town = $model->ville;
         $postalCode = $this->getPostalCode($town);
         if ($postalCode != null) {
             try {
                 $model->code_postal = $postalCode;
                 $model->update();
             } catch (Exception $e) {
                 echo 'Exception reçue pour le model: ' . $model->ville, $e->getMessage(), "\n";
             }
         }
     }
 }
예제 #14
0
 public function run($args)
 {
     //uppar case for each last name of contact
     $criteria = new EMongoCriteria();
     $criteria->sort('last_name', EMongoCriteria::SORT_ASC);
     $contacts = Contact::model()->findAll($criteria);
     foreach ($contacts as $model) {
         //last name to upper case automatically /prevent pb to sort and display
         // echo $model->_id."\n";
         $model->last_name = mb_strtoupper($model->last_name, "UTF-8");
         //convertie first name en lower case et mettant les caracteres en utf-8 ( cas possible de bug sur chaines mixtes)
         $model->first_name = mb_strtolower($model->first_name, "UTF-8");
         //phone without withespace, point a 0> +33
         $model->phone = mb_ereg_replace('/\\s+/', '', $model->phone);
         $model->phone = mb_ereg_replace('/\\./', '', $model->phone);
         //replace first zero and add +33
         $model->phone = mb_ereg_replace('/^0/', '+33', $model->phone);
         //pays = FR
         $model->pays = "FR";
         $model->inactive = 0;
         //catch exception on update if problem ( utf8 encoding  for example?)
         try {
             $model->update();
         } catch (Exception $e) {
             echo 'Exception reçue pour le model: ' . $model->_id . " " . $model->last_name . " " . $model->first_name, $e->getMessage(), "\n";
             //detection de le ncodage si pb d estring
             echo "first name encoding :" . mb_detect_encoding($model->first_name) . "\n";
         }
     }
     //update relation biobank->contact_id if old id contact, si ancien attribut id utilisé alors on mets le nouvel attribut _id
     $criteriaB = new EMongoCriteria();
     $criteriaB->sort('name', EMongoCriteria::SORT_ASC);
     $biobanks = Biobank::model()->findAll($criteriaB);
     foreach ($biobanks as $biobank) {
         $contact = Contact::model()->findByAttributes(array('id' => $biobank->contact_id));
         if ($contact != null) {
             // echo "current value from migration:" . $contact->last_name . " " . $contact->first_name."\n";
             $biobank->contact_id = $contact->_id;
             $biobank->update();
         }
     }
 }
예제 #15
0
 protected function validateAttribute($object, $attribute)
 {
     $criteria = array('condition' => '');
     if (false !== strpos($attribute, "+")) {
         $attributes = explode("+", $attribute);
     } else {
         $attributes = array($attribute);
     }
     $where = "";
     foreach ($attributes as $key => $attribute) {
         $where .= $attribute . "='" . $object->{$attribute} . "'";
         if (array_key_exists($key + 1, $attributes)) {
             $where .= ' AND ';
         }
     }
     $exists = Contact::model()->find($where);
     if (!empty($exists)) {
         $this->addError($object, $attributes[0], $this->message);
     }
 }
예제 #16
0
 public function actionDeleteContactLabel()
 {
     if (!($contactlabel = ContactLabel::model()->findByPk(@$_POST['contact_label_id']))) {
         throw new Exception("ContactLabel not found: " . @$_POST['contact_label_id']);
     }
     $count = Contact::model()->count('contact_label_id=?', array($contactlabel->id));
     if ($count == 0) {
         if (!$contactlabel->delete()) {
             throw new Exception("Unable to delete ContactLabel: " . print_r($contactlabel->getErrors(), true));
         }
         Audit::add('admin-ContactLabel', 'delete', @$_POST['contact_label_id']);
     }
     echo $count;
 }
예제 #17
0
 public function actionMarkread($id)
 {
     $contactModel = Contact::model();
     $contactModel = $contactModel->findByPk($id);
     $contactModel->isread = 1;
     $contactModel->save(false);
     $this->redirect(array('admin/message', 'm' => 2));
 }
예제 #18
0
 public function afterDelete($event)
 {
     if ($this->owner->contact_id && get_class($this->owner) != 'ContactLocation') {
         Address::model()->deleteAll('contact_id = :contact_id', array(':contact_id' => $this->owner->contact_id));
         Contact::model()->deleteByPk($this->owner->contact_id);
     }
     parent::afterDelete($event);
 }
예제 #19
0
 function modproject()
 {
     $clang = Yii::app()->lang;
     if (!Permission::model()->hasGlobalPermission('superadmin', 'read') || !Permission::model()->hasGlobalPermission('projects', 'update')) {
         Yii::app()->setFlashMessage($clang->gT("You do not have sufficient rights to access page."), 'error');
         $this->getController()->redirect(array("admin/index"));
     }
     $action = isset($_GET['action']) ? $_GET['action'] : '';
     if ($action == "editproject") {
         if ($_POST['submit'] == "Clone") {
             // Project details
             $project_name = "Clone-" . flattenText($_POST['project_name'], false, true, 'UTF-8', true);
             $project_friendly_name = flattenText($_POST['project_friendly_name'], false, true, 'UTF-8', true);
             $parent_project = (int) Yii::app()->request->getPost("parent_project");
             $client = (int) Yii::app()->request->getPost("client");
             $client_contact = (int) Yii::app()->request->getPost("client_contact");
             $project_manager = (int) Yii::app()->request->getPost("project_manager");
             $sales_person = (int) Yii::app()->request->getPost("sales_person");
             $country = (int) Yii::app()->request->getPost("country");
             $quota = flattenText($_POST['quota'], false, true, 'UTF-8', true);
             $maxcompletes = flattenText($_POST['maxcompletes'], false, true, 'UTF-8', true);
             if ($maxcompletes == 'percent0') {
                 $QuotaBufferAmnt = $quota;
             }
             if ($maxcompletes == 'percent10') {
                 $QuotaBufferAmnt = $quota + $quota * 0.1;
             }
             if ($maxcompletes == 'percent50') {
                 $QuotaBufferAmnt = $quota + $quota * 0.5;
             }
             if ($maxcompletes == 'percent100') {
                 $QuotaBufferAmnt = $quota * 2;
             }
             if ($maxcompletes == 'infinite') {
                 $QuotaBufferAmnt = 0;
             }
             $cpc = flattenText($_POST['cpc'], false, true, 'UTF-8', true);
             $los = flattenText($_POST['los'], false, true, 'UTF-8', true);
             $ir = flattenText($_POST['ir'], false, true, 'UTF-8', true);
             $points = flattenText($_POST['points'], false, true, 'UTF-8', true);
             $surveylink = flattenText($_POST['surveylink'], false, true, 'UTF-8', true);
             $notes = flattenText($_POST['notes'], false, true, 'UTF-8', true);
             $status = (int) getGlobalSetting('project_status_test');
             //$status = (int) Yii::app()->request->getPost("status");
             $RIDCheck = "Yes";
             $result = Yii::app()->db->createCommand("SELECT count(*) AS cnt FROM {{contact_master}} WHERE \n                            contact_id = '{$client}' AND RIDCheck = 'Yes'")->queryRow();
             if ($result['cnt'] <= 0) {
                 $RIDCheck = "No";
             }
             $internal_company = getGlobalSetting('Own_Panel');
             $CPC = $points / 100;
             $current_datetime = date('y-m-d h:i:s');
             $int_cmp = Contact::model()->findAll(array('condition' => 'contact_id = ' . $internal_company));
             $completed_link = $int_cmp[0]['completionlink'];
             $disqualify_link = $int_cmp[0]['disqualifylink'];
             $quotafull_link = $int_cmp[0]['quatafulllink'];
             if ($project_name == '') {
                 $aViewUrls['message'] = array('title' => $clang->gT("Failed to add Project"), 'message' => $clang->gT("A Project Name was not supplied or the Project Name is invalid."), 'class' => 'warningheader');
             } else {
                 $NewProject = Project::model()->instProject($project_name, $project_friendly_name, $parent_project, $client, $client_contact, $project_manager, $sales_person, $country, $quota, $QuotaBufferAmnt, $RIDCheck, $cpc, $los, $ir, $points, $surveylink, $notes, $status);
                 if ($NewProject) {
                     // create own panel
                     $newvendor = Project_vendor::model()->instvendor($NewProject, $internal_company, $internal_company, $status, 'Own Panel', $CPC, $quota, $QuotaBufferAmnt, $completed_link, $disqualify_link, $quotafull_link, '0', $current_datetime);
                     $sql = "INSERT INTO {{project_master_vendors}} \n                        (project_id,vendor_id,vendor_contact_id,vendor_status_id,notes,CPC,required_completes\n                        ,QuotaBuffer_Completes, completed_link,disQualified_link,QuotaFull_URL,max_redirects\n                        ,created_datetime)\n                        VALUES('{$NewProject}','{$internal_company}','{$internal_company}','{$status}','Own Panel'\n                        ,'{$CPC}','{$quota}','{$QuotaBufferAmnt}','{$completed_link}','{$disqualify_link}'\n                        ,'{$quotafull_link}','0','{$current_datetime}')";
                     //$result = Yii::app()->db->createCommand($sql)->query();
                     $loginuser = Yii::app()->session['user'];
                     // Update Message Table
                     $query = 'INSERT INTO {{messages}} (type_id, body, receipid, chainid, created )
                     VALUES (10,"Created by ' . $loginuser . '",0,"' . $NewProject . '", "' . $current_datetime . '")';
                     $result = Yii::app()->db->createCommand($query)->query();
                     Yii::app()->setFlashMessage($clang->gT("Project Cloned successfully"));
                     $this->getController()->redirect(array("admin/project/index"));
                 }
             }
         } else {
             $project_id = (int) Yii::app()->request->getPost("project_id");
             $project_name = flattenText($_POST['project_name'], false, true, 'UTF-8', true);
             $project_friendly_name = flattenText($_POST['project_friendly_name'], false, true, 'UTF-8', true);
             $parent_project = (int) Yii::app()->request->getPost("parent_project");
             $client = (int) Yii::app()->request->getPost("client");
             $client_contact = (int) Yii::app()->request->getPost("client_contact");
             $project_manager = (int) Yii::app()->request->getPost("project_manager");
             $sales_person = (int) Yii::app()->request->getPost("sales_person");
             $country = (int) Yii::app()->request->getPost("country");
             $quota = flattenText($_POST['quota'], false, true, 'UTF-8', true);
             $maxcompletes = flattenText($_POST['maxcompletes'], false, true, 'UTF-8', true);
             if ($maxcompletes == 'percent0') {
                 $QuotaBufferAmnt = $quota;
             }
             if ($maxcompletes == 'percent10') {
                 $QuotaBufferAmnt = $quota + $quota * 0.1;
             }
             if ($maxcompletes == 'percent50') {
                 $QuotaBufferAmnt = $quota + $quota * 0.5;
             }
             if ($maxcompletes == 'percent100') {
                 $QuotaBufferAmnt = $quota * 2;
             }
             if ($maxcompletes == 'infinite') {
                 $QuotaBufferAmnt = 0;
             }
             $cpc = flattenText($_POST['cpc'], false, true, 'UTF-8', true);
             $los = flattenText($_POST['los'], false, true, 'UTF-8', true);
             $ir = flattenText($_POST['ir'], false, true, 'UTF-8', true);
             $points = flattenText($_POST['points'], false, true, 'UTF-8', true);
             $surveylink = flattenText($_POST['surveylink'], false, true, 'UTF-8', true);
             $notes = flattenText($_POST['notes'], false, true, 'UTF-8', true);
             $status = (int) Yii::app()->request->getPost("status");
             $old_status = (int) Yii::app()->request->getPost("old_status");
             //$RIDCheck = flattenText($_POST['RIDCheck'], false, true, 'UTF-8', true);
             $internal_company = getGlobalSetting('Own_Panel');
             $CPC = $points / 100;
             $current_datetime = date('y-m-d h:i:s');
             $int_cmp = Contact::model()->findAll(array('condition' => 'contact_id = ' . $internal_company));
             $completed_link = $int_cmp[0]['completionlink'];
             $disqualify_link = $int_cmp[0]['disqualifylink'];
             $quotafull_link = $int_cmp[0]['quatafulllink'];
             if (Permission::model()->hasGlobalPermission('superadmin', 'read') || Permission::model()->hasGlobalPermission('projects', 'update')) {
                 if ($project_name == '') {
                     $aViewUrls['message'] = array('title' => $clang->gT("Failed to edit Project"), 'message' => $clang->gT("A Project Name was not supplied or the Project Name is invalid."), 'class' => 'warningheader');
                 } elseif (Project::model()->findByAttributes(array('project_name' => $project_name), 'project_id !=' . $project_id . '')) {
                     $aViewUrls['message'] = array('title' => $clang->gT("Failed to add Project"), 'message' => $clang->gT("The Project Name already exists."), 'class' => 'warningheader');
                 } else {
                     $oRecord = Project::model()->findByPk($project_id);
                     $oRecord->project_name = $project_name;
                     $oRecord->friendly_name = $project_friendly_name;
                     $oRecord->parent_project_id = $parent_project;
                     $oRecord->client_id = $client;
                     $oRecord->contact_id = $client_contact;
                     $oRecord->manager_user_id = $project_manager;
                     $oRecord->sales_user_id = $sales_person;
                     $oRecord->country_id = $country;
                     $oRecord->required_completes = $quota;
                     $oRecord->QuotaBuffer_Completes = $QuotaBufferAmnt;
                     $oRecord->CPC = $cpc;
                     $oRecord->IR = $ir;
                     $oRecord->expected_los = $los;
                     $oRecord->reward_points = $points;
                     $oRecord->client_link = $surveylink;
                     $oRecord->notes = $notes;
                     //$oRecord->RIDCheck = $RIDCheck;
                     $oRecord->project_status_id = $status;
                     if (isset($_POST['cleanedup'])) {
                         $oRecord->cleanedup = $_POST['cleanedup'];
                     }
                     if ($status == getGlobalSetting('project_status_closed')) {
                         $oRecord->closed = $current_datetime;
                     }
                     $EditContact = $oRecord->save();
                     if ($EditContact) {
                         // When saved successfully
                         //update cpc of project
                         $internal_company_id = getGlobalSetting('Own_Panel');
                         $sql = "UPDATE {{project_master_vendors}} SET CPC = '{$CPC}' \n                                WHERE project_id = '{$project_id}' and vendor_id = '{$internal_company_id}' and vendor_contact_id = '{$internal_company_id}'";
                         $result = Yii::app()->db->createCommand($sql)->query();
                         $loginuser = Yii::app()->session['user'];
                         // update message table
                         $query = 'INSERT INTO {{messages}} (type_id, body, receipid, chainid, created )
                         VALUES (10,"Information updated By ' . $loginuser . '","0","' . $project_id . '", "' . $current_datetime . '")';
                         $result = Yii::app()->db->createCommand($query)->query();
                         // if status is change
                         if ($old_status != $status) {
                             $sql = "SELECT status_name FROM {{project_status_master}} WHERE status_id = {$status}";
                             $result = Yii::app()->db->createCommand($sql)->queryRow();
                             $status_name = $result['status_name'];
                             $query = 'INSERT INTO {{messages}} (type_id, body, receipid, chainid, created )
                             VALUES (10,"Project status changed to ' . $status_name . ' by ' . $loginuser . '",0,"' . $project_id . '"," ' . $current_datetime . '" )';
                             $result = Yii::app()->db->createCommand($query)->query();
                         }
                         Yii::app()->setFlashMessage($clang->gT("Project updated successfully"));
                         $this->getController()->redirect(array("admin/project/sa/modifyproject/project_id/" . $project_id . "/action/modifyproject"));
                     } else {
                         $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing contact title"), $clang->gT("Could not modify contact title."), 'warningheader');
                     }
                 }
             } else {
                 Yii::app()->setFlashMessage(Yii::app()->lang->gT("You do not have sufficient rights to access this page."), 'error');
                 $this->getController()->redirect(array("admin/index"));
             }
         }
     } elseif ($action == "editvendor") {
         $project_id = (int) Yii::app()->request->getPost("project_id");
         $vendor_project_id = (int) Yii::app()->request->getPost("vendor_project_id");
         $vendor_id = (int) Yii::app()->request->getPost("panel");
         $vendor_contact = (int) Yii::app()->request->getPost("vendor_contact");
         $cpc = flattenText($_POST['cpc'], false, true, 'UTF-8', true);
         $maxredirects = flattenText($_POST['maxredirects'], false, true, 'UTF-8', true);
         $completionlink = flattenText($_POST['completionlink'], false, true, 'UTF-8', true);
         $disqualifylink = flattenText($_POST['disqualifylink'], false, true, 'UTF-8', true);
         $quatafulllink = flattenText($_POST['quatafulllink'], false, true, 'UTF-8', true);
         $quota = flattenText($_POST['quota'], false, true, 'UTF-8', true);
         $current_datetime = date('y-m-d h:i:s');
         $maxcompletes = flattenText($_POST['maxcompletes'], false, true, 'UTF-8', true);
         if ($maxcompletes == 'percent0') {
             $QuotaBufferAmnt = $quota;
         }
         if ($maxcompletes == 'percent10') {
             $QuotaBufferAmnt = $quota + $quota * 0.1;
         }
         if ($maxcompletes == 'percent50') {
             $QuotaBufferAmnt = $quota + $quota * 0.5;
         }
         if ($maxcompletes == 'percent100') {
             $QuotaBufferAmnt = $quota * 2;
         }
         if ($maxcompletes == 'infinite') {
             $QuotaBufferAmnt = 0;
         }
         $notes = flattenText($_POST['notes'], false, true, 'UTF-8', true);
         $status = (int) Yii::app()->request->getPost("status");
         $AskOnRedirect = "";
         if (isset($_POST['askEmail'])) {
             $AskOnRedirect .= 'Email';
         }
         if (isset($_POST['askZip'])) {
             $AskOnRedirect .= 'Zip';
         }
         if (isset($_POST['askAge'])) {
             $AskOnRedirect .= 'Age';
         }
         if (isset($_POST['askGender'])) {
             $AskOnRedirect .= 'Gender';
         }
         $oRecord = Project_vendor::model()->findByPk($vendor_project_id);
         $oRecord->vendor_id = $vendor_id;
         $oRecord->vendor_contact_id = $vendor_contact;
         $oRecord->vendor_status_id = $status;
         $oRecord->notes = $notes;
         $oRecord->CPC = $cpc;
         $oRecord->required_completes = $quota;
         $oRecord->QuotaBuffer_Completes = $QuotaBufferAmnt;
         $oRecord->completed_link = $completionlink;
         $oRecord->disQualified_link = $disqualifylink;
         $oRecord->QuotaFull_URL = $quatafulllink;
         $oRecord->max_redirects = $maxredirects;
         $oRecord->AskOnRedirect = $AskOnRedirect;
         $oRecord->created_datetime = $current_datetime;
         $EditContact = $oRecord->save();
         $sql = "UPDATE {{project_master_vendors}}\n                    SET\n                    vendor_id = '{$vendor_id}' , \n                    vendor_contact_id = '{$vendor_contact}' , \n                    vendor_status_id = '{$status}' , \n                    notes = '{$notes}' ,  \n                    CPC = '{$cpc}' , \n                    required_completes = '{$quota}' , \n                    QuotaBuffer_Completes = '{$QuotaBufferAmnt}' , \n                    completed_link = '{$completionlink}' , \n                    disQualified_link = '{$disqualifylink}' , \n                    QuotaFull_URL = '{$quatafulllink}' , \n                    max_redirects = '{$maxredirects}' , \n                    AskOnRedirect = '{$AskOnRedirect}' , \n                    created_datetime = '{$current_datetime}'\n                    WHERE\n                    vendor_project_id = '{$vendor_project_id}'";
         //$result = Yii::app()->db->createCommand($sql)->query();
         Yii::app()->setFlashMessage($clang->gT("Vendor updated successfully"));
         $this->getController()->redirect(array("admin/project/sa/modifyproject/project_id/{$project_id}/action/modifyproject"));
         exit;
     } else {
         Yii::app()->setFlashMessage(Yii::app()->lang->gT("You do not have sufficient rights to access this page."), 'error');
     }
     $aViewUrls = array();
     $this->_renderWrappedTemplate('projects', $aViewUrls);
 }
예제 #20
0
파일: User.php 프로젝트: jayrulez/yiisns
 public static function areContacts($userId, $contactId)
 {
     $contact = Contact::model()->findBySql("SELECT l.* \n\t\t\tFROM contact AS l INNER JOIN contact as r ON (l.user_id=r.contact_id AND l.contact_id=r.user_id) \n\t\t\tWHERE l.user_id=:user_id AND l.contact_id=:contact_id\n\t\t", array(':user_id' => $userId, ':contact_id' => $contactId));
     return $contact !== null;
 }
예제 #21
0
파일: _form.php 프로젝트: rodespsan/LMEC
						$("#Order_contact_id").children().remove();
						$("#Order_contact_id").append( new Option("Seleccionar"));
						$("#Order_payment_type_id > option[value=]").attr("selected","selected");
					}')));
?>
		<?php 
echo $form->error($model, 'customer_id');
?>
	</div>
	
	<div class="row">
		<?php 
echo $form->labelEx($model, 'contact_id');
?>
		<?php 
echo $form->dropDownList($model, 'contact_id', CHtml::listData(Contact::model()->findAll(array('with' => array('customer'), 'condition' => 't.active = 1 AND customer.id = :customer_id', 'order' => 't.name', 'params' => array(':customer_id' => $model->customer_id))), 'id', 'name'), array('prompt' => 'Seleccionar'));
?>
		<?php 
echo $form->error($model, 'contact_id');
?>
	</div>
	
	<div class="row">
		<?php 
echo $form->labelEx($model, 'receptionist_user_id');
?>
		<?php 
echo $form->dropDownList($model, 'receptionist_user_id', CHtml::listData(User::model()->findAll(array('with' => array('roles'), 'condition' => 'role_id = 3 AND t.active = 1', 'order' => 't.name')), 'id', 'fullName'), array('prompt' => 'Seleccionar'));
?>
		<?php 
echo $form->error($model, 'receptionist_user_id');
예제 #22
0
 protected function changeConstant()
 {
     $uid = Ibos::app()->user->uid;
     $cuid = intval(EnvUtil::getRequest("cuid"));
     $status = EnvUtil::getRequest("status");
     if ($status == "mark") {
         Contact::model()->addConstant($uid, $cuid);
     } elseif ($status == "unmark") {
         Contact::model()->deleteConstant($uid, $cuid);
     }
     $this->ajaxReturn(array("isSuccess" => true));
 }
예제 #23
0
			<th>Subject</th>
			<th>Body</th>
			<th>Date</th>
		
		</thead>
	
	<div class ="text-center">
		hello you are in the inbox 
	</div>
	<div class="text-center" >	



	<?php 
$model = new Contact();
$row = Contact::model()->findAll();
foreach ($row as $value) {
    Yii::app()->user->setState('subject', $value->subject);
    Yii::app()->user->setState('email', $value->email);
    echo "\n\t\t\n\t\t\t\n\n\t\t\t\t<tbody>\n\t\t\t\t\n\t\t\t\t\t<td>{$value->name}</td>\n\t\t\t\t\t<td>{$value->email}</td>\n\t\t\t\t\t\t<td>{$value->subject}</td>\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t<td>{$value->body}</td>\n\t\t\t\t\t<td>{$value->date}</td>\n                                                \n\n\t\t\t\t</tbody>\n\t\t\t\t\t";
    echo '<td>';
    echo CHtml::link('<button class="btn btn-primary" type="submit">delete</button>', array('site/delete'));
    echo '</td>';
    echo '<td>';
    echo CHtml::link('<button class="btn btn-danger" type="submit">reply</button>', array('site/reply'));
    echo '</td>';
}
?>

<table>
</body>
예제 #24
0
 public function actionEditContact()
 {
     if (!($patient = Patient::model()->findByPk(@$_POST['patient_id']))) {
         throw new Exception("Patient not found: " . @$_POST['patient_id']);
     }
     if (!($contact = Contact::model()->findByPk(@$_POST['contact_id']))) {
         throw new Exception("Contact not found: " . @$_POST['contact_id']);
     }
     if (@$_POST['site_id']) {
         if (!($site = Site::model()->findByPk(@$_POST['site_id']))) {
             throw new Exception("Site not found: " . @$_POST['site_id']);
         }
         if (!($cl = ContactLocation::model()->find('contact_id=? and site_id=?', array($contact->id, $site->id)))) {
             $cl = new ContactLocation();
             $cl->contact_id = $contact->id;
             $cl->site_id = $site->id;
             if (!$cl->save()) {
                 throw new Exception("Unable to save contact location: " . print_r($cl->getErrors(), true));
             }
         }
     } else {
         if (!($institution = Institution::model()->findByPk(@$_POST['institution_id']))) {
             throw new Exception("Institution not found: " . @$_POST['institution_id']);
         }
         if (!($cl = ContactLocation::model()->find('contact_id=? and institution_id=?', array($contact->id, $institution->id)))) {
             $cl = new ContactLocation();
             $cl->contact_id = $contact->id;
             $cl->institution_id = $institution->id;
             if (!$cl->save()) {
                 throw new Exception("Unable to save contact location: " . print_r($cl->getErrors(), true));
             }
         }
     }
     if (!($pca = PatientContactAssignment::model()->findByPk(@$_POST['pca_id']))) {
         throw new Exception("PCA not found: " . @$_POST['pca_id']);
     }
     $pca->location_id = $cl->id;
     if (!$pca->save()) {
         throw new Exception("Unable to save patient contact assignment: " . print_r($pca->getErrors(), true));
     }
     $this->redirect(array('/patient/view/' . $patient->id));
 }
예제 #25
0
 /**
  * Envoie une demande aux contacts des biobanques concernées par une demande
  */
 public function actionEnvoyer()
 {
     if (isset($_GET['demande_id'])) {
         $demande = $this->loadModel($_GET['demande_id']);
         if (!empty($demande->titre) && !empty($demande->detail) && !empty($demande->sampleList)) {
             $samples = $demande->getArraySamples();
             $biobankIdList = $demande->getBiobanksFromSamples($samples);
             $demandeSent = false;
             foreach ($biobankIdList as $biobankId) {
                 $biobank = Biobank::model()->findByPk(new MongoId($biobankId));
                 if ($biobank->contact_id != null) {
                     $contact = Contact::model()->findByPk(new MongoId($biobank->contact_id));
                     if ($contact != null) {
                         $concernSamplesList = array();
                         foreach ($samples as $sample) {
                             if ($sample->biobank_id == $biobankId) {
                                 $concernSamplesList[] = $sample;
                             }
                         }
                         // PB si pas envoyer a une biuobank alors pas sauvegarder
                         if (CommonMailer::sendDemande($contact, $demande->titre . ' : ' . $biobank->identifier, $demande->detail, $concernSamplesList) == 1) {
                             $demandeSent = true;
                         }
                     } else {
                     }
                 }
             }
             if ($demandeSent) {
                 $demande->envoi = 1;
                 $demande->save();
                 $this->actionCreateNewDemand();
                 Yii::app()->user->setFlash('success', 'Votre demande a bien été envoyée aux différents sites');
                 $this->render('view', array_merge(array('model' => $this->loadModel($demande->_id), isset($_GET['layout']) || isset($layout) && $layout != null ? array('layout' => $_GET['layout']) : array())));
             } else {
                 Yii::app()->user->setFlash('error', 'Un problème est apparu, les demandes n\'ont pas été transmises');
                 $this->redirect(array_merge(array('updateAndSend', 'id' => Yii::app()->session['activeDemand'][0]->_id), isset($_GET['layout']) ? array('layout' => $_GET['layout']) : array()));
                 //
             }
         } else {
             Yii::app()->user->setFlash('notice', 'Merci de completer votre demande avant de l\'envoyer');
             $this->redirect(array_merge(array('updateAndSend', 'id' => $demande->_id), isset($_GET['layout']) ? array('layout' => $_GET['layout']) : array()));
             //
         }
     }
 }
예제 #26
0
 public function actionLostpassword()
 {
     $contact = Contact::model()->findByAttributes(array('email' => $_POST['email'], 'parent_model' => 'Customer'));
     if ($contact == null && $contact == '') {
         echo CJSON::encode($this->statusError('Email not valid'));
         Yii::app()->end();
     }
     $customer = Customer::model()->findByPk($contact->parent_id);
     $customer->key = Yii::app()->hasher->hashPassword(time() . $contact->email);
     if ($customer->update()) {
         echo CJSON::encode($this->statusSuccess($customer));
     }
 }
예제 #27
0
$parent_project = Project::model()->findAll(array('condition' => "parent_project_id = '0'"));
$parent_project_list = CHtml::listData($parent_project, 'project_id', 'project_name');
echo CHtml::dropDownList('parent_project', '', $parent_project_list, array('prompt' => 'Select Parent Project'));
?>
        </td>
    </tr>
    <tr>
        <td style="text-align: right;">
            <label for='client'><?php 
$clang->eT("Client : ");
?>
</label>
        </td>
        <td>
            <?php 
$company = Contact::model()->findAll(array('condition' => "contact_type_id = '1'"));
$company_list = CHtml::listData($company, 'contact_id', 'company_name');
echo CHtml::dropDownList('client', '', $company_list, array('prompt' => 'Select Client', 'ajax' => array('type' => 'POST', 'data' => array('client_id' => 'js:this.value'), 'url' => CController::createUrl('admin/project/sa/selectclientcontact'), 'update' => '#client_contact'), 'required' => true));
?>
        </td>
        <td style="text-align: right;">
            <label for='client_contact'><?php 
$clang->eT("Client Contact : ");
?>
</label>
        </td>
        <td>
            <?php 
echo CHtml::dropDownList('client_contact', '', array(), array('prompt' => 'Select Contact', 'required' => true));
?>
        </td>
예제 #28
0
파일: _form.php 프로젝트: nmalservet/biocap
        if (is_object($model->{$attName})) {
            foreach ($model->{$attName}->attributeNames() as $emAtt) {
                $count++;
                if ($count % 2 == 0) {
                    echo ' <td>';
                } else {
                    echo '<tr><td width="400px">';
                }
                ?>

                        <?php 
                echo $form->labelEx($model->{$attName}, $emAtt);
                ?>
                        <?php 
                if ($emAtt == "country") {
                    echo $form->dropDownList($model->{$attName}, $emAtt, Contact::model()->getArrayCountries());
                } else {
                    echo $form->textField($model->{$attName}, $emAtt);
                }
                ?>
                        <?php 
                echo $form->error($model->{$attName}, $emAtt);
            }
        } else {
            ?>

                    <?php 
            echo $form->labelEx($model, $attName);
            ?>
                    <?php 
            echo $form->textField($model, $attName);
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Contact::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'Запрашиваемая страница не существует.');
     }
     return $model;
 }
예제 #30
0
 public static function arrQuestionPracivnuk()
 {
     $pracivnuk_id = Pracivnuku::getIdPracivnuk(Yii::app()->user->name);
     return Contact::model()->findAll("pracivnuk_id='{$pracivnuk_id}'");
 }