public static function boot() { parent::boot(); static::creating(function ($workerunit) { // dd($workerunit); // Inherit type, domain and format if (empty($workerunit->type) or empty($workerunit->domain) or empty($workerunit->format)) { $j = Job::where('_id', $workerunit->job_id)->first(); $workerunit->type = $j->type; $workerunit->domain = $j->domain; $workerunit->format = $j->format; } $workerunit->annotationVector = $workerunit->createAnnotationVector(); // Activity if not exists if (empty($workerunit->activity_id)) { try { $activity = new Activity(); $activity->label = "Workerunit is saved."; $activity->softwareAgent_id = $workerunit->softwareAgent_id; $activity->save(); $workerunit->activity_id = $activity->_id; Log::debug("Saving workerunit {$workerunit->_id} with activity {$workerunit->activity_id}."); } catch (Exception $e) { if ($activity) { $activity->forceDelete(); } //if($workerunit) $workerunit->forceDelete(); throw new Exception('Error saving activity for workerunit.'); } } }); }
function logActivity($action, $body = null) { $activity = new Activity($this); $name = $this->logName(); $activity->body = "{$action} {$activity->target_class} {$activity->target_id}" . ($name ? ", \"{$name}\"" : ""); $activity->save(); }
/** * Store to the database the given entities as entities decendent from the given * document. * * @param $document Parent document -- Must be a document entity on the database. * @param $entities List of entities to be created as decendents from the given document. * * @return multitype:string A status array containing the result status information. */ public function store($parent, $units, $type) { if (count($units) <= 0 && count($units) >= 10000) { // We will have problems processing empty files or more than 10,000 entities return ['error' => 'Unable to process files with more than 10,000 lines: ' . $nEnts . 'found']; } $activity = new \Activity(); $activity->softwareAgent_id = $this->softwareComponent->_id; $activity->save(); $entities = []; foreach ($units as $unit) { try { $entity = new Unit(); $entity->project = $parent->project; $entity->activity_id = $activity->_id; $entity->documentType = $type; $entity->parents = [$parent->_id]; $entity->content = $unit; $entity->hash = md5(serialize($entity)); $entity->save(); array_push($entities, $entity); } catch (Exception $e) { foreach ($entities as $en) { $en->forceDelete(); } throw $e; } } \Temp::truncate(); return ['success' => 'Sentences created successfully']; }
public function postAddActivity() { $company_id = Session::get('company'); $validator = Validator::make(Input::all(), array('type' => 'required|max:100', 'outcome' => 'required|max:200', 'name' => 'required|max:100', 'date' => 'required')); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } else { $type = Input::get('type'); $outcome = Input::get('outcome'); $name = Input::get('name'); $date = Input::get('date'); $activity = new Activity(); $activity->type = $type; $activity->outcome = $outcome; $activity->sales_p_name = $name; $activity->date = $date; $activity->cutomer_id = $company_id; $insertedToActivity = $activity->save(); if ($insertedToActivity) { return Redirect::route('dashboard'); } else { return Redirect::route('activityAdd'); } } }
function log($activity) { $act = new Activity(); $act->message = $activity; $act->user_id = Auth::user()->id; $act->save(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Activity(); $model->attributes = $_POST; $result = $model->save(); $this->sendAjaxResponse($model); }
function afterFind(\Model $model, $results, $primary) { parent::afterFind($model, $results, $primary); if ($model->id) { $data = array('model' => $model->alias, 'model_id' => $model->id, 'activity_type' => 'R', 'user_id' => $model->loginUser['id']); $activity = new Activity(); $activity->save($data); } }
protected function getOldActivity($subject, $created) { $activity = new Activity(['subject_id' => $subject->getKey(), 'subject_type' => get_class($subject), 'user_id' => 1, 'name' => 'created_post']); $time = Carbon::createFromTimestamp($created)->toDateTimeString(); $activity->setCreatedAt($time); $activity->setUpdatedAt($time); $activity->save(); return $activity; }
public static function log($activity, User $user = null) { if ($user === null) { $user = User::$me; } $a = new Activity(); $a->set('user_id', $user->id); $a->set('action_date', date("Y-m-d H:i:s")); $a->set('activity', $activity); $a->save(); return $a; }
public function store() { $activity = new Activity(); $activity->project_id = Auth::user()->curr_project_id; $activity->location_id = Input::get('location'); $activity->name = Input::get('name'); $activity->description = Input::get('description'); $activity->agenda = Input::get('agenda'); $activity->coordination = Input::get('coordination'); $activity->save(); Session::flash('message', 'Sukses menambahkan agenda baru'); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Activity(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Activity'])) { $model->attributes = $_POST['Activity']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->act_id)); } } $this->render('create', array('model' => $model)); }
public function store() { $ac = new Activity(); $ac->user_id = Auth::user()->id; $ac->site_id = Input::get('site'); $ac->problem = Input::get('problem'); $ac->activity = Input::get('activity'); $ac->detail_activity = Input::get('dactivity'); $ac->mulai = Carbon::parse(Input::get('mulai')); $ac->selesai = Carbon::parse(Input::get('selesai')); $ac->save(); Session::flash('success', 'Data telah dibuat.'); return Redirect::to('/' . Auth::user()->role . '/activity'); }
function TraceIncomingCall() { require_once 'include/utils/utils.php'; global $adb, $current_user; global $theme, $app_strings; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $sql = "select * from vtiger_asteriskextensions where userid = " . $current_user->id; $result = $adb->query($sql); $asterisk_extension = $adb->query_result($result, 0, "asterisk_extension"); $query = "select * from vtiger_asteriskincomingcalls where to_number = " . $asterisk_extension; $result = $adb->query($query); if ($adb->num_rows($result) > 0) { $callerNumber = $adb->query_result($result, 0, "from_number"); $callerName = $adb->query_result($result, 0, "from_name"); $callerType = $adb->query_result($result, 0, "callertype"); if (!empty($callerType)) { $caller = getCallerName("{$callerType}:" . $callerNumber); } else { $caller = getCallerName($callerNumber); } $adb->query("delete from vtiger_asteriskincomingcalls where to_number = " . $asterisk_extension); //prepare the div for incoming calls $status = "\t<table border='0' cellpadding='5' cellspacing='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style='padding:10px;' colspan='2'><b>Incoming Call</b></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t<table border='0' cellpadding='0' cellspacing='0' class='hdrNameBg'>\n\t\t\t\t\t\t<tr><td style='padding:10px;' colspan='2'><b>Caller Information</b>\n\t\t\t\t\t\t\t<br><b>Number:</b> {$callerNumber}\n\t\t\t\t\t\t\t<br><b>Name:</b> {$callerName}\n\t\t\t\t\t\t</td></tr>\n\t\t\t\t\t\t<tr><td style='padding:10px;' colspan='2'><b>Information from vtigerCRM</b>\n\t\t\t\t\t\t\t<br>{$caller}\n\t\t\t\t\t\t</td></tr>\n\t\t\t\t\t</table>"; require_once 'modules/Calendar/Activity.php'; $focus = new Activity(); $focus->column_fields['subject'] = "Incoming call from {$callerName} ({$callerNumber})"; $focus->column_fields['activitytype'] = "Call"; $focus->column_fields['date_start'] = date('Y-m-d'); $focus->column_fields['due_date'] = date('Y-m-d'); $focus->column_fields['time_start'] = date('H:i'); $focus->column_fields['time_end'] = date('H:i'); $focus->column_fields['eventstatus'] = "Held"; $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->save('Calendar'); $callerInfo = getCallerInfo("{$callerType}:" . $callerNumber); if ($callerInfo == false) { $callerInfo = getCallerInfo(getStrippedNumber($callerNumber)); } if ($callerInfo != false) { $tablename = array('Contacts' => 'vtiger_cntactivityrel', 'Accounts' => 'vtiger_seactivityrel', 'Leads' => 'vtiger_seactivityrel'); $sql = "insert into " . $tablename[$callerInfo['module']] . " values (?,?)"; $params = array($callerInfo[id], $focus->id); $adb->pquery($sql, $params); } } else { $status = "failure"; } return $status; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Activity(); // Associate goal with current user. $model->userId = Yii::app()->user->id; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Activity'])) { $model->attributes = $_POST['Activity']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model, 'goals' => Goal::model()->findAllByAttributes(array('userId' => $model->userId)))); }
/** * Test Activity */ public function testActivityCRUD() { $activity = new Activity(); $activity->_id = \app\locker\helpers\Helpers::getRandomValue(); $activity->definition = array('type' => \app\locker\helpers\Helpers::getRandomValue(), 'name' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue()), 'description' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue())); $result = $activity->save(); $this->assertTrue($result); // Load activity from db $aid = $activity->_id; $db_activity = Activity::find($aid); $this->assertEquals($db_activity->_id, $activity->_id); // Delete activity $db_activity->delete(); $this->assertEquals(Activity::find($aid), NULL); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Activity(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Activity'])) { $model->attributes = $_POST['Activity']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->activity_id)); } } if (isset($_POST['ActivityForm']) || isset($_GET['activity_id'])) { if (!Yii::app()->user->isGuest) { if (isset($_POST['ActivityForm']) && $_POST['ActivityForm']['activity_id'] == 0) { $model->attributes = $_POST['ActivityForm']; $model->author_id = Yii::app()->user->getId(); $model->save(); $activity_id = $model->activity_id; } elseif (isset($_GET['activity_id'])) { $activity_id = $_GET['activity_id']; } else { $activity_id = $_POST['ActivityForm']['activity_id']; } $link = new ActivityUser(); $link->activity_id = $activity_id; $link->user_id = Yii::app()->user->getId(); if (!$link->save()) { CVarDumper::dump($link->getErrors(), 10, true); exit; } } // if ($model->save()) $this->redirect(array('site/index')); } $this->render('create', array('model' => $model)); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aActivity !== null) { if ($this->aActivity->isModified() || $this->aActivity->isNew()) { $affectedRows += $this->aActivity->save($con); } $this->setActivity($this->aActivity); } if ($this->isNew()) { $this->modifiedColumns[] = ReservationreasonPeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = ReservationreasonPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += ReservationreasonPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } if ($this->collReservations !== null) { foreach ($this->collReservations as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
function add() { $model = new Activity(); if (isset($_POST['activity']) and $_POST['activity']['name'] != '' and $_POST['activity']['point'] != '') { $activity = $_POST['activity']; $name = $activity['name']; $point = $activity['point']; $model->name = $name; $model->point = $point; if ($model->save()) { header('Location: ' . 'index.php?url=activity/index'); die; } } else { $this->set("title", "Error! Empty field!"); } }
public function login($member_id) { $this->layout = ''; $member = Member::find($member_id); if (!empty($member) && is_object($member)) { if ($member->memberpackages->count() > 0) { $activity = new Activity(); $activity->member_id = $member_id; $activity->timestamp = date("Y-m-d H:i:s"); $activity->save(); return Redirect::to('/'); } else { return Redirect::to('/')->with('error', 'Member doesnt have any package.'); } } else { return Redirect::to('/'); } }
protected function beforeSave() { if ($this->isNewRecord) { // ToDo: Handle this via event of User Module if ($this->object_model == 'User') { // Create Wall Activity for that $activity = new Activity(); $activity->content->user_id = $this->user->id; $activity->content->visibility = Content::VISIBILITY_PUBLIC; $activity->type = "ActivityUserFollowsUser"; $activity->object_model = "User"; $activity->object_id = $this->object_id; $activity->save(); $activity->content->addToWall($this->user->wall_id); } } return parent::beforeSave(); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aUsergroup !== null) { if ($this->aUsergroup->isModified() || $this->aUsergroup->isNew()) { $affectedRows += $this->aUsergroup->save($con); } $this->setUsergroup($this->aUsergroup); } if ($this->aActivity !== null) { if ($this->aActivity->isModified() || $this->aActivity->isNew()) { $affectedRows += $this->aActivity->save($con); } $this->setActivity($this->aActivity); } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = UsergroupHasActivityPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setNew(false); } else { $affectedRows += UsergroupHasActivityPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
public static function boot() { parent::boot(); static::saving(function ($questiontemplate) { if (empty($questiontemplate->activity_id)) { try { $activity = new Activity(); $activity->label = "Questiontemplate is saved."; $activity->softwareAgent_id = 'templatebuilder'; $activity->save(); $questiontemplate->activity_id = $activity->_id; Log::debug("Saving QuestionTemplate {$questiontemplate->_id} with activity {$questiontemplate->activity_id}."); } catch (Exception $e) { if ($activity) { $activity->forceDelete(); } if ($questiontemplate) { $questiontemplate->forceDelete(); } throw new Exception('Error saving activity for QuestionTemplate.'); } } }); }
public function test_1_n_1() { $this->installAndIncludeModels(array('Activity', 'Kid', 'Father')); $Activity1 = new Activity(array('name' => 'Test1')); $Activity2 = new Activity(array('name' => 'Test2')); $Child1 = new Kid(array('name' => 'Johanna')); $Child2 = new Kid(array('name' => 'John')); $Father = new Father(array('name' => 'Daddy')); $Child1->father->assign($Father); $Child2->father->assign($Father); $Activity1->kid->assign($Child1); $Activity2->kid->assign($Child2); $Child1->save(); $Child2->save(); $Activity1->save(); $Activity2->save(); $Test = $Father->findFirstBy('name', 'Daddy', array('include' => array('kid' => array('order' => 'id ASC', 'include' => array('activities' => array('order' => 'id ASC')))))); $this->assertEqual($Test->name, 'Daddy'); $this->assertEqual($Test->kids[0]->name, 'Johanna'); $this->assertEqual($Test->kids[1]->name, 'John'); $this->assertEqual($Test->kids[0]->activities[0]->name, 'Test1'); $this->assertEqual($Test->kids[1]->activities[0]->name, 'Test2'); //die; }
public static function log($content) { $activity = new Activity(); $activity->setContent($content); $activity->save(); }
/** * Manages all models. */ public function actionAdmin() { date_default_timezone_set("Asia/Manila"); $activity = new Activity(); $activity->act_desc = 'Viewed Position List'; $activity->act_datetime = date('Y-m-d G:i:s'); $activity->act_by = User::model()->findByPK(Yii::app()->user->name)->emp_id; $activity->save(); $model = new Position('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['Position'])) { $model->attributes = $_GET['Position']; } $this->render('admin', array('model' => $model)); }
public function storeVideoSegments($parentEntity, $videoSegmenting) { $tempEntityID = null; $status = array(); try { $this->createVideoSegmentingSoftwareAgent(); } catch (Exception $e) { $status['error']['videosegmenting'] = $e->getMessage(); return $status; } try { $activity = new Activity(); $activity->softwareAgent_id = "videosegmenting"; $activity->save(); } catch (Exception $e) { // Something went wrong with creating the Activity $activity->forceDelete(); $status['error'][$title] = $e->getMessage(); return $status; } for ($i = 0; $i < sizeof($videoSegmenting); $i++) { $videoSegmentName = explode("/", $videoSegmenting[$i]["storage_url"]); $title = $videoSegmentName[sizeof($videoSegmentName) - 1]; try { $entity = new Entity(); $entity->_id = $tempEntityID; $entity->title = strtolower($title); $entity->domain = $parentEntity->domain; $entity->format = "video"; $entity->documentType = "videosegment"; $entity->parents = array($parentEntity->_id); $entity->source = $parentEntity->source; $entity->content = $videoSegmenting[$i]; //unset($relexStructuredSentenceKeyVal['properties']); $entity->hash = md5(serialize($videoSegmenting[$i])); $entity->activity_id = $activity->_id; $entity->save(); $status['success'][$title] = $title . " was successfully processed into a video segment. (URI: {$entity->_id})"; } catch (Exception $e) { // Something went wrong with creating the Entity $entity->forceDelete(); $status['error'][$title] = $e->getMessage(); } $tempEntityID = $entity->_id; } $status['success']['noEntitiesCreated'] = sizeof($videoSegmenting); //dd($status); return $status; }
/** * Remove Membership * * @param $userId UserId of User to Remove */ public function removeMember($userId = "") { if ($userId == "") { $userId = Yii::app()->user->id; } $user = User::model()->findByPk($userId); $membership = $this->getMembership($userId); if ($this->isRoomOwner($userId)) { return false; } if ($membership == null) { return true; } // If was member, create a activity for that if ($membership->status == RoomMembership::STATUS_MEMBER) { $activity = new Activity(); $activity->content->room_id = $this->getOwner()->id; $activity->content->visibility = Content::VISIBILITY_PRIVATE; $activity->type = "ActivityRoomMemberRemoved"; $activity->created_by = $userId; $activity->save(); $activity->fire(); } // Was invited, but declined the request if ($membership->status == RoomMembership::STATUS_INVITED) { RoomInviteDeclinedNotification::fire($membership->originator_user_id, $user, $this->getOwner()); } foreach (RoomMembership::model()->findAllByAttributes(array('user_id' => $userId, 'room_id' => $this->getOwner()->id)) as $membership) { $membership->delete(); } // Cleanup Notifications RoomApprovalRequestNotification::remove($userId, $this->getOwner()); RoomInviteNotification::remove($userId, $this->getOwner()); RoomApprovalRequestNotification::remove($userId, $this->getOwner()); }
} $date = new DateTimeField($_REQUEST['task_date_start'] . ' ' . $_REQUEST['task_time_start']); $endDate = new DateTimeField($_REQUEST['task_due_date'] . ' ' . $_REQUEST['task_time_start']); $focus->column_fields["taskstatus"] = $_REQUEST["taskstatus"]; $focus->column_fields["date_start"] = $date->getDBInsertDateValue(); $focus->column_fields["time_start"] = $date->getDBInsertTimeValue(); $focus->column_fields["due_date"] = $endDate->getDBInsertDateValue(); $focus->column_fields["time_end"] = $endDate->getDBInsertTimeValue(); $focus->column_fields["taskpriority"] = $_REQUEST["taskpriority"]; $focus->column_fields["parent_id"] = $_REQUEST["task_parent_id"]; $focus->column_fields["contact_id"] = $_REQUEST["task_contact_id"]; $focus->column_fields["description"] = $_REQUEST["task_description"]; if (isset($_REQUEST['task_sendnotification']) && $_REQUEST['task_sendnotification'] != null) { $focus->column_fields["sendnotification"] = $_REQUEST["task_sendnotification"]; } $focus->save($tab_type); function getRequestedToData() { $mail_data = array(); $mail_data['user_id'] = $_REQUEST["task_assigned_user_id"]; $mail_data['subject'] = $_REQUEST['task_subject']; $mail_data['status'] = $_REQUEST['activity_mode'] == 'Task' ? $_REQUEST['taskstatus'] : $_REQUEST['eventstatus']; $mail_data['activity_mode'] = $_REQUEST['activity_mode']; $mail_data['taskpriority'] = $_REQUEST['taskpriority']; $mail_data['relatedto'] = $_REQUEST['task_parent_name']; $mail_data['contact_name'] = $_REQUEST['task_contact_name']; $mail_data['description'] = $_REQUEST['task_description']; $mail_data['assign_type'] = $_REQUEST['task_assigntype']; $mail_data['group_name'] = getGroupName($_REQUEST['task_assigned_group_id']); $mail_data['mode'] = $_REQUEST['task_mode']; $startTime = $_REQUEST['task_time_start'];
public function actionIndex() { date_default_timezone_set("Asia/Manila"); $activity = new Activity(); $activity->act_desc = 'Searched Statistical Resolution Report'; $activity->act_datetime = date('Y-m-d G:i:s'); $activity->act_by = User::model()->findByPK(Yii::app()->user->name)->emp_id; $activity->save(); $months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $jan = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-01%"'))); $feb = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-02%"'))); $mar = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-03%"'))); $apr = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-04%"'))); $may = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-05%"'))); $jun = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-06%"'))); $jul = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-07%"'))); $aug = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-08%"'))); $sep = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-09%"'))); $oct = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-10%"'))); $nov = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-11%"'))); $dec = count(Resolution::model()->findAll(array('condition' => 'date_passed like "' . date('Y') . '-12%"'))); $months_data = array($jan, $feb, $mar, $apr, $may, $jun, $jul, $aug, $sep, $oct, $nov, $dec); $sql = 'select distinct substring(res_no,6,9) as reso from tbl_resolution order by date_passed asc'; $connection = Yii::app()->db; $command = $connection->createCommand($sql); $years = $command->queryAll(); $y = array(); foreach ($years as $value) { array_push($y, count(Resolution::model()->findAll(array('condition' => 'res_no like "%' . $value['reso'] . '"')))); } $this->render('index', array('months' => $months, 'months_data' => $months_data, 'years' => $years, 'years_data' => $y)); }
function addOutgoingcallHistory($current_user, $extension, $record, $adb) { global $log; require_once 'modules/Calendar/Activity.php'; $date = new DateTimeField(null); $currentDate = $date->getDisplayDate(); $currentTime = $date->getDisplayTime(); $focus = new Activity(); $focus->column_fields['subject'] = "Outgoing call from {$current_user->user_name} ({$extension})"; $focus->column_fields['activitytype'] = "Call"; $focus->column_fields['date_start'] = $currentDate; $focus->column_fields['due_date'] = $currentDate; $focus->column_fields['time_start'] = $currentTime; $focus->column_fields['time_end'] = $currentTime; $focus->column_fields['eventstatus'] = "Held"; $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->save('Calendar'); $focus->setActivityReminder('off'); $setype = $adb->pquery("SELECT setype FROM vtiger_crmentity WHERE crmid = ?", array($record)); $rows = $adb->num_rows($setype); if ($rows > 0) { $module = $adb->query_result($setype, 0, 'setype'); $tablename = array('Contacts' => 'vtiger_cntactivityrel', 'Accounts' => 'vtiger_seactivityrel', 'Leads' => 'vtiger_seactivityrel'); $sql = "insert into " . $tablename[$module] . " values (?,?)"; $params = array($record, $focus->id); $adb->pquery($sql, $params); $status = "success"; } else { $status = "failure"; } return $status; }