/** * @param PageBuilder $pageBuilder * @return ContactsPanel */ function ContactsPanel(&$pagebuilder) { $this->_pagebuilder =& $pagebuilder; $this->_proc =& $pagebuilder->_proc; $this->_pagebuilder->AddJSFile('./classic/base.contactsmain.js'); $this->_pagebuilder->_top->AddOnResize('ResizeElements(\'all\');'); $this->_pagebuilder->AddJSText(' function ViewAdressRecord(idstring) { var record = ParseCId(idstring); var cmode = (record.type == "c") ? "' . C_VIEW . '" : "' . G_VIEW . '"; document.location = "' . BASEFILE . '?' . CONTACT_MODE . '=" + cmode + "&' . CONTACT_ID . '=" + record.cid; } '); $this->contactList =& new ContactsList($this->_pagebuilder); $this->contactViewer =& new ContactsViewer($this->_pagebuilder); $this->footText = ''; if (isset($GLOBALS['contactCount']) && isset($GLOBALS['contactCount'][0])) { $this->footText .= (int) $GLOBALS['contactCount'][0] . ' ' . JS_LANG_ContactsCount; //$this->footText .= ' / '; //$this->footText .= ((int) $GLOBALS['contactCount'][1]).' '.JS_LANG_GroupsCount; } $this->text .= '<div class="wm_contacts" id="main_contacts">' . $this->contactList->ToHTML() . $this->contactViewer->ToHTML() . ' <div id="lowtoolbar" class="wm_lowtoolbar"> <span class="wm_lowtoolbar_messages"> ' . $this->footText . ' </span> </div>'; }
protected function getTotalcontacts() { $criteria = new CDbCriteria(); $criteria->condition = '`group_id`=:group_id'; $criteria->params = array(":group_id" => $this->id); return ContactsList::model()->count($criteria); }
public function actionSave() { $response = array('status' => 'failed'); if (Yii::app()->request->isAjaxRequest) { if (isset($_POST['datas']) and $_POST['datas'] != "" and isset($_POST['import_fields']) and count($_POST['import_fields']) > 0) { $datas = json_decode($_POST['datas']); $fields = $_POST['import_fields']; $start = 1; $singlequery = false; $inserted_rows = 0; $requiredattributes = array(); if (Contacts::model()->import_contacts_config()) { $import_config = Contacts::model()->import_contacts_config(); if ($import_config['required_attributes']) { $requiredattributes = $import_config['required_attributes']; } } $valid = true; foreach ($fields as $field => $value) { if (in_array($field, $requiredattributes) and $value == NULL) { $valid = false; } } if (!$valid) { $response['data'] = $this->renderPartial('import/_error', array('error' => 2), true); } else { while ($start < count($datas)) { if (!$singlequery) { $contact = new Contacts(); $contact->created_by = Yii::app()->user->id; $contact->created_at = date('Y-m-d H:i:s'); $contact->status = 1; foreach ($fields as $field => $value) { if ($value != NULL) { $contact->{$field} = $datas[$start][$value]; } } if ($contact->save()) { $inserted_rows++; if (isset($_POST['groups']) and count($_POST['groups']) > 0) { foreach ($_POST['groups'] as $group) { $list = new ContactsList(); $list->contact_id = $contact->id; $list->group_id = $group; $list->save(); } } } } $start++; } $response['status'] = "success"; $response['data'] = $this->renderPartial('import/_step3', array('inserted_rows' => $inserted_rows, 'total_rows' => count($datas) - 1), true); } } } echo json_encode($response); Yii::app()->end(); }
public function actionDeletegroups() { if (isset($_POST['groups']) and count($_POST['groups']) > 0) { $groups = $_POST['groups']; foreach ($groups as $group) { if ($this->loadModel($group)->delete()) { ContactsList::model()->deleteAllByAttributes(array('group_id' => $group)); } } } }
<?php $criteria = new CDbCriteria(); $criteria->condition = '`group_id`=' . $_GET['group']; $alllists = ContactsList::model()->findAll($criteria); $contact_ids = array(); foreach ($alllists as $list) { $contact_ids[] = $list->contact_id; } $criteria = new CDbCriteria(); $criteria->addNotInCondition('id', $contact_ids); $remaining = Contacts::model()->findAll($criteria); if (count($remaining) > 0) { ?> <div class="clear"></div> <h2>Move these also</h2> <div class="remaining_contacts"> <?php foreach ($remaining as $contact) { ?> <div class="remain-contact-bx" data-contact-id="<?php echo $contact->id; ?> "> <?php echo '<b>' . $contact->fullname . '</b> : ' . $contact->mobile; ?> </div> <?php } if (count($remaining) > 0) {