本文整理汇总了PHP中Contact::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::model方法的具体用法?PHP Contact::model怎么用?PHP Contact::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
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: actionIndex
public function actionIndex()
{
$criteriaContact = new CDbCriteria();
$criteriaContact->limit = 10;
$criteriaContact->order = "id DESC";
$contact = Contact::model()->findAll($criteriaContact);
$this->render('index', compact('contact'));
}
示例3: loadModel
/**
* 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: delete
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;
}
示例5: init
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);
}
示例6: loadData
/**
* 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: actionDelete
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: actionGetContentByID
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: beforeDelete
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: beforeDelete
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: actionExportCsv
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: actionIndex
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: run
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: run
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: validateAttribute
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);
}
}