/** * Handle on_dashboard_important_section event * * @param NamedList $items * @param User $user * @return null */ function resources_handle_on_dashboard_important_section(&$items, &$user) { if ($reminders_count = Reminders::countActiveByUser($user)) { $items->add('reminders', array('label' => $reminders_count > 1 ? lang('<strong>:count</strong> reminders', array('count' => $reminders_count)) : lang('<strong>:count</strong> reminder', array('count' => $reminders_count)), 'class' => 'reminders', 'icon' => get_image_url('important.gif'), 'url' => assemble_url('reminders'))); } // if }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Lead(); $result = new User(); $res = User::Model()->findallByattributes(array('superuser' => 2)); $leaduser = new LeadUsers(); $prop = Priority::Model()->findall(); $rem = Reminders::Model()->findall(); if (isset($_POST['Lead'])) { /* $model->reminder_time=$_POST['Lead']['reminder_time'].':'.$_POST['Lead']['sec']; */ $model->status = 1; $model->min_size = $_POST['Lead']['min_size']; $model->max_size = $_POST['Lead']['max_size']; $model->retailer_webiste = $_POST['Lead']['retailer_webiste']; $model->broker_firstname = $_POST['Lead']['broker_firstname']; $model->broker_lastname = $_POST['Lead']['broker_lastname']; $model->broker_territory = $_POST['Lead']['broker_territory']; $model->broker_company = $_POST['Lead']['broker_company']; /* $model->broker_phone_no= $_POST['broker_phone_no']; $model->broker_cell_no= $_POST['broker_cell_no']; $model->broker_email= $_POST['broker_email']; */ $model->linked_username = $_POST['Lead']['linked_username']; $model->enquiry_date = $_POST['enquiry_date']; $model->create_at = date('Y-m-d-h:i:sa'); $model->country = $_POST['country']; /* $model->reminder_date=$_POST['reminder_date']; */ $model->user_id = Yii::app()->user->id; $model->attributes = $_POST['Lead']; /* echo "<pre>"; print_r(array($model->attributes,$_POST)); */ if ($model->save()) { /* if(isset($_POST['reminder_date'])){ $Last_id = $model->id; $status = 1; Yii::app()->db->createCommand("INSERT INTO `tbl_reminders`(`lead_id`,`date`,`time`,`msg`,`status` ) VALUES ('".$Last_id."', '".$_POST['reminder_date']."','".$_POST['Lead']['reminder_time'].":".$_POST['Lead']['sec']."','".$_POST['Lead']['message']."','".$status."')" )->execute(); } */ $this->redirect(array('admin')); } } $this->render('create', array('model' => $model, 'models' => $res, 'props' => $prop)); }
/** * Clean up system by object ID-s * * This function cleans up project objects recursively. It is also infinite * loop safe because it will filter out ID-s that are already removed * * @param array $ids * @return null */ function cleanUpByIds($ids) { static $cleaned_ids = array(); // Remove objects that are already cleaned if (is_foreachable($ids)) { foreach ($ids as $k => $id) { if (isset($cleaned_ids[$id]) && $cleaned_ids[$id]) { unset($ids[$k]); } else { $cleaned_ids[$id] = false; } // if } // foreach } // if if (is_foreachable($ids)) { db_begin_work(); Attachments::deleteByProjectObjectIds($ids); Subscriptions::deleteByObjectIds($ids); Assignments::deleteByObjectIds($ids); ActivityLogs::deleteByObjectIds($ids); StarredObjects::deleteByObjectIds($ids); Reminders::deleteByObjectIds($ids); search_index_remove($ids, 'ProjectObject'); $rows = db_execute_all('SELECT DISTINCT id FROM ' . TABLE_PREFIX . 'project_objects WHERE parent_id IN (?)', $ids); if (is_foreachable($rows)) { $subobject_ids = array(); foreach ($rows as $row) { $subobject_ids[] = (int) $row['id']; } // foreach ProjectObjects::cleanUpByIds($subobject_ids); } // if ProjectObjects::delete(array('id IN (?)', $ids)); foreach ($ids as $id) { $cleaned_ids[$id] = true; } // if db_commit(); } // if return true; }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'Reminders')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return Reminders::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& Reminders::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
/** * Delete from database * * @param void * @return boolean */ function delete() { db_begin_work(); $delete = parent::delete(); if ($delete && !is_error($delete)) { unlink($this->getAvatarPath()); unlink($this->getAvatarPath(true)); ProjectUsers::deleteByUser($this); Assignments::deleteByUser($this); Subscriptions::deleteByUser($this); StarredObjects::deleteByUser($this); PinnedProjects::deleteByUser($this); UserConfigOptions::deleteByUser($this); Reminders::deleteByUser($this); search_index_remove($this->getId(), 'User'); $cleanup = array(); event_trigger('on_user_cleanup', array(&$cleanup)); if (is_foreachable($cleanup)) { foreach ($cleanup as $table_name => $fields) { foreach ($fields as $field) { $condition = ''; if (is_array($field)) { $id_field = array_var($field, 'id'); $name_field = array_var($field, 'name'); $email_field = array_var($field, 'email'); $condition = array_var($field, 'condition'); } else { $id_field = $field . '_id'; $name_field = $field . '_name'; $email_field = $field . '_email'; } // if if ($condition) { db_execute('UPDATE ' . TABLE_PREFIX . "{$table_name} SET {$id_field} = 0, {$name_field} = ?, {$email_field} = ? WHERE {$id_field} = ? AND {$condition}", $this->getName(), $this->getEmail(), $this->getId()); } else { db_execute('UPDATE ' . TABLE_PREFIX . "{$table_name} SET {$id_field} = 0, {$name_field} = ?, {$email_field} = ? WHERE {$id_field} = ?", $this->getName(), $this->getEmail(), $this->getId()); } // if } // foreach } // foreach } // if db_commit(); return true; } else { db_rollback(); return $delete; } // if }
/** * 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 Reminders the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Reminders::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Return manager instance * * @access protected * @param void * @return ProjectForms */ function manager() { if (!$this->manager instanceof Reminders) { $this->manager = Reminders::instance(); } return $this->manager; }
function send_reports() { $company = Companies::findById(1); $lTime = time() + 60 * 60 * $company->getTimezone(); $dayOfWeek = date("l", $lTime); $footer = '<a href="' . externalUrl(ROOT_URL) . '">' . externalUrl(ROOT_URL) . "</a>"; $people = Reminders::findAll(array('conditions' => 'reports_enabled = 1 and report_day = "' . $dayOfWeek . '"')); if (is_array($people) && count($people)) { foreach ($people as $person) { tpl_assign('settings', $person); $user = Users::findById($person->getUserId()); tpl_assign('user', $user); $offset = 60 * 60 * $user->getTimezone(); tpl_assign('offset', $offset); $allProjects = $user->getProjects(); $emailBody = ''; $recipient = Notifier::prepareEmailAddress($user->getEmail(), $user->getDisplayName()); foreach ($allProjects as $project) { if ($project->isActive() || $project->getCompletedOn()->getLeftInDays() > -7) { tpl_assign('project', $project); $condition = 'project_id = ' . $project->getId(); $condition .= " and is_private = 0 and is_silent = 0"; if (!$person->getReportsIncludeEveryone()) { $condition .= ' and taken_by_id = ' . $user->getId(); } $logs = array(); if ($person->getReportsIncludeActivity()) { $condition .= " and created_on > Interval -7 day + now()"; $logs = ApplicationLogs::findAll(array('conditions' => $condition)); } tpl_assign('logs', $logs); $taskLists = $project->getAllTaskLists(); $emailTaskLists = array(); if (is_array($taskLists) && count($taskLists)) { foreach ($taskLists as $taskList) { $condition = 'task_list_id = ' . $taskList->getId(); if (!$person->getReportsIncludeEveryone()) { $condition .= " and assigned_to_user_id = " . $user->getId(); } $condition .= " and completed_on > Interval -7 day + now()"; $tasks = ProjectTasks::findAll(array('conditions' => $condition)); if (is_array($tasks) && count($tasks)) { $emailTaskLists[] = $taskList; } } } if (count($emailTaskLists) || count($logs)) { tpl_assign('taskLists', $emailTaskLists); $emailBody .= tpl_fetch(get_template_path('report_per_project', 'reminders')); if ($person->getReportsSummarizedBy()) { try { Notifier::sendEmail($recipient, $recipient, "[ProjectPier] - Project Report - " . $project->getObjectName(), $emailBody . $footer, 'text/html'); // send $emailBody = ''; } catch (Exception $e) { echo $e; } } } } } if (strlen($emailBody) && !$person->getReportsSummarizedBy()) { $time = time() + 60 * 60 * $user->getTimezone(); try { Notifier::sendEmail($recipient, $recipient, "[ProjectPier] - Activity Report - " . gmdate('Y/m/d', $time), $emailBody . $footer, 'text/html'); // send $emailBody = ''; } catch (Exception $e) { echo $e; } } } } }
?> Reminder has been deleted successfully. <?php } ?> <?php if ($_REQUEST['message'] == 'update') { ?> Reminder has been updated successfully. <?php } ?> </div> <?php } $reminder_query = new Reminders(); ?> <?php if (isset($_REQUEST['show_non_expired'])) { $reminder_query->showNonExpired(); } else { $reminder_query->showAll(); } ?> <!--Start div For Form--> <div id="add_form"> <ul class="menu"> <li><a href="#"><span>Add Reminder</span></a></li> </ul> <script src='js/gen_validatorv5.js' type='text/javascript'></script>
<?php require 'reminders.php'; $newReminder = new Reminders(); $newReminder->title = $_REQUEST['title']; $newReminder->description = $_REQUEST['description']; $newReminder->start_date = 1; $newReminder->expire_date = $_REQUEST['expire_date']; $reminder_query = new Reminders(); $reminder_query->add($newReminder);
/** * Delete this object * * If $drop_subitems is TRUE subitems will be delete from the database. If it * is false relation will be nullified * * @param boolean $drop_subitems * @return boolean * @throws DBQueryError */ function delete($drop_subitems = true) { db_begin_work(); $delete = parent::delete(); if (is_error($delete) || !$delete) { db_rollback(); return $delete; } // if $subitems = $this->getSubitems(); if (is_foreachable($subitems)) { foreach ($subitems as $subitem) { if ($drop_subitems) { $delete = $subitem->delete(); if (is_error($delete)) { db_rollback(); return $delete; } // if } else { $subitem->setParent(null, false); $save = $subitem->save(); if (is_error($save)) { db_rollback(); return $save; } // if } // if } // foreach } // if StarredObjects::deleteByObject($this); // Attachments if ($this->can_have_attachments) { Attachments::deleteByObject($this); } // if // Subscriptions if ($this->can_have_subscribers) { Subscriptions::deleteByParent($this); } // if // Asignments if ($this->can_have_assignees) { Assignments::deleteByObject($this); } // if // Activity log if ($this->log_activities) { ActivityLogs::deleteByObject($this); } // if // Reminders if ($this->can_send_reminders) { Reminders::deleteByObject($this); } // if search_index_remove($this->getId(), 'ProjectObject'); db_commit(); return true; }
/** * Delete reminders by object ID-s * * @param array $ids * @return boolean */ function deleteByObjectIds($ids) { return Reminders::delete(array('object_id IN (?)', $ids)); }
/** * List active reminders for user * * @param void * @return null * */ function index() { $this->smarty->assign(array('active_reminders' => Reminders::findActiveByUser($this->logged_user))); }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Reminders</title> <link rel="stylesheet" href="css/styles.css" /> <script type="text/javascript" src="js/DateTimePicker.js"></script> </head> <body> <div style="width:400px; margin:0px auto;"> <a href="index.php"><img src="images/images.jpg" width="100" height="100"/><br /> </a><ul class="menu"> <li><a href="index.php"><span>Home</span></a></li> </ul> <div id="add_form"> <?php if (isset($_REQUEST['id'])) { $reminder_query = new Reminders(); $reminder_query->show($_REQUEST['id']); ?> <?php } ?> </div> </div> </body> </html>