Ejemplo n.º 1
0
 public static function sendMail($layout, $recipient)
 {
     $mailer = JFactory::getMailer();
     $mailer->isHTML(true);
     $mailer->Encoding = 'base64';
     $config = JFactory::getConfig();
     $sender = array($config->getValue('config.mailfrom'), $config->getValue('config.fromname'));
     $mailer->setSender($sender);
     $mailer->addRecipient($recipient);
     $mailer->setSubject(TextHelper::_('COBALT_COFFEE_REPORT_SUBJECT') . ' ' . DateHelper::formatDate(date('Y-m-d')));
     ob_start();
     $layout->display();
     $body = ob_get_contents();
     ob_end_clean();
     $mailer->setBody($body);
     $send = $mailer->Send();
     if ($send !== true) {
         echo 'Error sending email: ' . $send->message;
     }
 }
Ejemplo n.º 2
0
 /**
  * Mark events as completed
  * @return [type] [description]
  */
 public function markComplete()
 {
     $app = \Cobalt\Container::fetch('app');
     //Determine if we are editing a series of events of a single event
     $event_id = $app->input->get('event_id');
     $parent_id = $app->input->get('parent_id');
     $date = $app->input->get('due_date') ? $app->input->get('due_date') : $app->input->get('date');
     $event_type = $app->input->get('event_type');
     $repeats = $app->input->get('repeats');
     $completed = $app->input->get('completed') != "" ? $app->input->get('completed') : 1;
     //Load Tables
     $oldRow = new EventTable();
     $oldRow->load($event_id);
     //We are only editing a single event entry OR a parent entry
     if ($repeats == 'none') {
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         $date = DateHelper::formatDBDate(date("Y-m-d H:i:s"));
         $query->update("#__events")->set(array('completed=' . $completed, 'actual_close="' . $date . '"'))->where("id=" . $event_id);
         $db->setQuery($query);
         $db->execute();
         //We are dealing with a virtually generated event
     } else {
         $id = $parent_id > 0 ? $parent_id : $event_id;
         //Clone the event and give it the correct // new unique completion date
         $event = $this->getEvent($id, false);
         //Add the event to the parent exclusion
         $exp1 = explode(" ", $date);
         $append = $event->type == "task" ? $event->due_date : $event->start_time;
         $exp2 = explode(" ", $append);
         $excludeDate = $exp1[0] . " " . $exp2[1];
         $this->addExcludes($id, $excludeDate);
         //Merge arrays
         $data = $app->input->getRequest('post');
         $data['completed'] = $completed;
         $new_data = array_merge($event, $data);
         if ($event->type == "task") {
             $new_data['due_date'] = DateHelper::formatDate($excludeDate, false, false);
             $new_data['type'] = "task";
         } else {
             $new_data['start_time'] = DateHelper::formatDate($excludeDate, false, false);
             $new_data['end_time'] = DateHelper::formatDate($excludeDate, false, false);
             $new_data['type'] = "event";
         }
         unset($new_data['id']);
         unset($new_data['repeats']);
         unset($new_data['excludes']);
         // unset($new_data['parent_id']);
         foreach ($new_data as $key => $data) {
             if (is_null($data)) {
                 $new_data[$key] = 0;
             }
         }
         //Store new data
         $id = $this->store($new_data);
         $event = $this->getEvent($id);
         //echo json_encode($event);
     }
     $row = new EventTable();
     $row->load($event_id);
     $status = "completed";
     ActivityHelper::saveActivity($oldRow, $row, 'event', $status);
     return JFactory::getDbo()->getAffectedRows() ? true : false;
 }
Ejemplo n.º 3
0
 /**
  * Prepare HTML field templates for each dataTable column.
  *
  * @param   string column name
  * @param   object of item
  * @return  string HTML template for propper field
  */
 public function getDataTableFieldTemplate($column, $item)
 {
     switch ($column) {
         case 'id':
             $template = '<input type="checkbox" class="export" name="ids[]" value="' . $item->id . '" />';
             break;
         case 'name':
             $template = '<a href="' . RouteHelper::_('index.php?view=deals&layout=deal&id=' . $item->id) . '">' . $item->name . '</a>';
             break;
         case 'company_name':
             $template = '<a href="' . RouteHelper::_('index.php?view=companies&layout=company&id=' . $item->company_id) . '">' . $item->company_name . '</a>';
             break;
         case 'amount':
             $template = ConfigHelper::getCurrency() . $item->amount;
             break;
         case 'status_name':
             if (!isset($item->status_id) || !$item->status_id) {
                 $item->status_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $statuses = DealHelper::getStatuses(null, true);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="deal_status_' . $item->id . '_link">';
             $template .= '  <span class="deal-status-' . $item->status_name . '">' . $item->status_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_status_' . $item->id . '" role="menu">';
             if (isset($statuses) && count($statuses)) {
                 foreach ($statuses as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="status_select dropdown_item" data-field="status_id" data-item="deal" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="deal-status-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'stage_name':
             if (!isset($item->stage_id) || !$item->stage_id) {
                 $item->stage_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $stages = DealHelper::getStages(null, true);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="deal_stage_' . $item->id . '_link">';
             $template .= '  <span class="deal-stage-' . $item->stage_name . '">' . $item->stage_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_stage_' . $item->id . '" role="menu">';
             if (isset($stages) && count($stages)) {
                 foreach ($stages as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="stage_select dropdown_item" data-field="stage_id" data-item="deal" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="deal-stage-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'source_name':
             if (!isset($item->source_id) || !$item->source_id) {
                 $item->source_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $sources = DealHelper::getSources(null, true);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="deal_source_' . $item->id . '_link">';
             $template .= '  <span class="deal-source-' . $item->source_name . '">' . $item->source_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_source_' . $item->id . '" role="menu">';
             if (isset($sources) && count($sources)) {
                 foreach ($sources as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="source_select dropdown_item" data-field="source_id" data-item="deal" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="deal-source-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'expected_close':
             if ($item->expected_close == "0000-00-00 00:00:00") {
                 $template = TextHelper::_('COBALT_NOT_SET');
             } else {
                 $template = DateHelper::formatDate($item->expected_close);
             }
             break;
         case 'actual_close':
             if ($item->actual_close == "0000-00-00 00:00:00") {
                 $template = TextHelper::_('COBALT_ACTIVE_DEAL');
             } else {
                 $template = DateHelper::formatDate($item->actual_close);
             }
             break;
         case 'action':
             $template = '<div class="btn-group">';
             // @TODO: make these 2 buttons work
             // $template .= ' <a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_CONTACTS').'" data-placement="bottom" class="btn" href="javascript:void(0);" onclick="Cobalt.showDealContactsDialogModal('.$item->id.');"><i class="glyphicon glyphicon-user"></i></a>';
             // $template .= ' <a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_NOTES').'" data-placement="bottom" class="btn" href="javascript:void(0);" onclick="openNoteModal(\'.deal->id.\',\'deal\');"><i class="glyphicon glyphicon-file"></i></a>';
             $template .= ' <a data-toggle="popover" title="' . TextHelper::_('COBALT_VIEW_DETAILS') . '" data-placement="top" data-html="true" data-content-class="extras-' . $item->id . '" class="btn btn-xs btn-default" href="#" tabindex="0"><i class="glyphicon glyphicon-info-sign"></i></a>';
             $template .= '</div>';
             $template .= '<div class="extras-' . $item->id . ' hide">';
             $template .= ' <b>' . TextHelper::_('COBALT_PRIMARY_CONTACT') . '</b>';
             $template .= ' <a href="' . RouteHelper::_('index.php?view=people&layout=person&id=' . $item->primary_contact_id) . '">' . $item->primary_contact_first_name . '</a><br>';
             $template .= ' <b>' . TextHelper::_('COBALT_NEXT_ACTION') . '</b><br>';
             $template .= '</div>';
             break;
         default:
             if (isset($column) && isset($item->{$column})) {
                 $template = $item->{$column};
             } else {
                 $template = '';
             }
             break;
     }
     return $template;
 }
Ejemplo n.º 4
0
 /**
  * Get custom field values from picklists // forecasts // otherwise return the value as it was an input field
  */
 public static function getCustomValue($customType, $customNameOrId, $customValue, $itemId)
 {
     $db = \Cobalt\Container::fetch('db');
     $query = $db->getQuery(true);
     $id = str_replace("custom_", "", $customNameOrId);
     $query->select("c.type,c.values")->from("#__" . $customType . "_custom AS c")->where("c.id=" . $id);
     $db->setQuery($query);
     $custom = $db->loadObject();
     switch ($custom->type) {
         case "forecast":
             $query->clear();
             $query->select("(d.amount * ( d.probability / 100 )) AS amount")->from("#__deals AS d")->where("d.id=" . $itemId);
             $db->setQuery($query);
             $result = $db->loadResult();
             return ConfigHelper::getCurrency() . $result;
             break;
         case "currency":
             return ConfigHelper::getCurrency() . $customValue;
             break;
         case "picklist":
             $values = json_decode($custom->values);
             return array_key_exists($customValue, $values) ? $values[$customValue] : TextHelper::_('COBALT_NONE');
             break;
         case "date":
             return DateHelper::formatDate($customValue);
             break;
         default:
             return $customValue;
             break;
     }
     return $customValue;
 }
Ejemplo n.º 5
0
 public function getConversation($id)
 {
     //initialize query
     $query = $this->db->getQuery(true)->select("c.*, u.first_name as owner_first_name, u.last_name as owner_last_name,author.email")->from("#__conversations as c")->where("c.id=" . (int) $id)->where("c.published=" . $this->published)->leftJoin("#__users AS u ON u.id = c.author")->leftJoin("#__users AS author on author.id=u.id");
     $results = $db->setQuery($query)->loadAssocList();
     //clean results
     if (count($results) > 0) {
         foreach ($results as $key => $convo) {
             $results[$key]['created_formatted'] = DateHelper::formatDate($convo['created']);
             $results[$key]['owner_avatar'] = CobaltHelper::getGravatar($convo['email']);
         }
     }
     return $results;
 }
Ejemplo n.º 6
0
 public function getNotes($object_id = NULL, $type = NULL, $display = true)
 {
     $app = \Cobalt\Container::fetch('app');
     //grab db
     $db = JFactory::getDBO();
     //initialize query
     $query = $db->getQuery(true);
     //gen query string
     $query->select("n.*,cat.name as category_name,comp.name as company_name,\n                        comp.id as company_id,deal.name as deal_name,deal.id as deal_id,\n                        person.id as person_id,person.first_name as person_first_name,\n                        person.last_name as person_last_name, owner.first_name as owner_first_name,\n                        event.name as event_name, event.id as event_id,\n                        owner.last_name as owner_last_name, author.email");
     $query->from("#__notes as n");
     $query->leftJoin("#__notes_categories AS cat ON cat.id = n.category_id");
     $query->leftJoin("#__companies AS comp ON comp.id = n.company_id AND comp.published>0");
     $query->leftJoin("#__events AS event ON event.id = n.event_id AND event.published>0");
     $query->leftJoin("#__deals AS deal ON deal.id = n.deal_id AND deal.published>0");
     $query->leftJoin("#__people AS person on n.person_id = person.id AND person.published>0");
     $query->leftJoin("#__users AS owner ON n.owner_id = owner.id");
     $query->leftJoin("#__users AS author ON author.id = owner.id");
     $company_filter = $this->getState('Note.company_name');
     if ($company_filter != null) {
         $query->where("comp.name LIKE '%" . $company_filter . "%'");
     }
     //deal
     $deal_filter = $this->getState('Note.deal_name');
     if ($deal_filter != null) {
         $query->where("deal.name LIKE '%" . $deal_filter . "%'");
     }
     //person
     $person_filter = $this->getState('Note.person_name');
     if ($person_filter != null) {
     }
     if ($object_id) {
         switch ($type) {
             case 'person':
             case 'people':
                 $query->where('n.person_id =' . $object_id);
                 break;
             case 'company':
                 $query->where('(n.company_id =' . $object_id . ' OR deal.company_id = ' . $object_id . ' OR person.company_id = ' . $object_id . ")");
                 break;
             case 'deal':
                 $query->where('n.deal_id=' . $object_id);
                 break;
             case "event":
                 $query->where("n.event_id={$object_id}");
                 break;
         }
     }
     //owner
     $owner_filter = $this->getState('Note.owner_id');
     if ($owner_filter != null && $owner_filter != "all") {
         $owner_type = $this->getState('Note.owner_type');
         switch ($owner_type) {
             case "team":
                 $team_member_ids = UsersHelper::getTeamUsers($owner_filter, TRUE);
                 $query->where("n.owner_id IN (" . implode(',', $team_member_ids) . ")");
                 break;
             case "member":
                 $query->where("n.owner_id=" . $owner_filter);
                 break;
         }
     }
     //created
     $created_filter = $this->getState('Note.created');
     if ($company_filter != null) {
     }
     //category
     $category_filter = $this->getState('Note.category_id');
     if ($category_filter != null) {
         $query->where("n.category_id=" . $category_filter);
     }
     if ($this->_id) {
         if (is_array($this->_id)) {
             $query->where("n.id IN (" . implode(',', $this->_id) . ")");
         } else {
             $query->where("n.id={$this->_id}");
         }
     }
     /** ---------------------------------------------------------------
      * Filter data using member role permissions
      */
     $member_id = UsersHelper::getUserId();
     $member_role = UsersHelper::getRole();
     $team_id = UsersHelper::getTeamId();
     if ($this->public_notes != true) {
         if ($member_role != 'exec') {
             //manager filter
             if ($member_role == 'manager') {
                 $query->where('owner.team_id = ' . $team_id);
             } else {
                 //basic user filter
                 $query->where(array('n.owner_id = ' . $member_id));
             }
         }
     }
     $query->where("n.published=" . $this->published);
     $query->order("n.modified DESC");
     //load results
     $db->setQuery($query);
     $results = $db->loadAssocList();
     //clean results
     if (count($results) > 0) {
         foreach ($results as $key => $note) {
             $results[$key]['created_formatted'] = DateHelper::formatDate($note['created']);
             $results[$key]['owner_avatar'] = CobaltHelper::getGravatar($note['email']);
         }
     }
     //$app->triggerEvent('onNoteLoad', array(&$results));
     if (!$display) {
         //return results
         return $results;
     } else {
         $notesView = ViewHelper::getView('note', 'default', 'phtml', array('notes' => $results));
         return $notesView;
     }
 }
Ejemplo n.º 7
0
 /**
  * Prepare HTML field templates for each dataTable column.
  *
  * @param   string column name
  * @param   object of item
  * @return  string HTML template for propper field
  */
 public function getDataTableFieldTemplate($column, $item)
 {
     switch ($column) {
         case 'id':
             $template = '<input type="checkbox" class="export" name="ids[]" value="' . $item->id . '" />';
             break;
         case 'avatar':
             if (isset($item->avatar) && $item->avatar) {
                 $template = '<img id="avatar_img_' . $item->id . '" data-item-type="people" data-item-id="' . $item->id . '" class="avatar" src="' . JURI::base() . 'src/Cobalt/media/avatars/' . $item->avatar . '"/>';
             } else {
                 $template = '<img id="avatar_img_' . $item->id . '" data-item-type="people" data-item-id="' . $item->id . '" class="avatar" src="' . JURI::base() . 'src/Cobalt/media/images/person.png' . '"/>';
             }
             break;
         case 'name':
             $template = '<a href="' . RouteHelper::_('index.php?view=people&layout=person&id=' . $item->id) . '">' . $item->first_name . ' ' . $item->last_name . '</a>';
             break;
         case 'company_name':
             $template = '<a href="' . RouteHelper::_('index.php?view=companies&layout=company&id=' . $item->company_id) . '">' . $item->company_name . '</a>';
             break;
         case 'owner':
             if (!isset($item->owner_last_name) || !$item->owner_last_name) {
                 $item->status_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $me = array(array('label' => TextHelper::_('COBALT_ME'), 'value' => UsersHelper::getLoggedInUser()->id));
             $users = UsersHelper::getUsers(null, true);
             $users = array_merge($me, $users);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="oerson_owner_' . $item->id . '_link">';
             $template .= $item->owner_first_name . ' ' . $item->owner_last_name;
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_status_' . $item->id . '" role="menu">';
             if (isset($users) && count($users)) {
                 foreach ($users as $id => $user) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="owner_select dropdown_item" data-field="owner_id" data-item="person" data-item-id="' . $item->id . '" data-value="' . $user['value'] . '">';
                     $template .= '    <span class="person-owner-' . OutputFilter::stringURLUnicodeSlug($user['value']) . '">' . $user['label'] . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'status_name':
             if (!isset($item->status_id) || !$item->status_id) {
                 $item->status_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $statuses = PeopleHelper::getStatusList();
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="deal_stage_' . $item->id . '_link">';
             $template .= '  <span class="person-status-' . $item->status_name . '">' . $item->status_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="deal_stage_' . $item->id . '" role="menu">';
             if (isset($statuses) && count($statuses)) {
                 foreach ($statuses as $id => $status) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="status_select dropdown_item" data-field="status_id" data-item="people" data-item-id="' . $item->id . '" data-value="' . $status['id'] . '">';
                     $template .= '    <span class="person-status-' . OutputFilter::stringURLUnicodeSlug($status['id']) . '">' . $status['name'] . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'source_name':
             if (!isset($item->source_id) || !$item->source_id) {
                 $item->source_name = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $sources = DealHelper::getSources(null, true);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="person_source_' . $item->id . '_link">';
             $template .= '  <span class="person-source-' . $item->source_name . '">' . $item->source_name . '</span>';
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="person_source_' . $item->id . '" role="menu">';
             if (isset($sources) && count($sources)) {
                 foreach ($sources as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="source_select dropdown_item" data-field="source_id" data-item="people" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="person-source-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'type':
             if (!isset($item->type) || !$item->type) {
                 $item->type = TextHelper::_('COBALT_CLICK_TO_EDIT');
             }
             $types = PeopleHelper::getPeopleTypes(false);
             $template = '<div class="dropdown">';
             $template .= ' <a href="#" class="dropdown-toggle update-toggle-html" role="button" data-toggle="dropdown" id="person_type_' . $item->id . '_link">';
             $template .= $item->type;
             $template .= ' </a>';
             $template .= ' <ul class="dropdown-menu" aria-labelledby="person_type_' . $item->id . '" role="menu">';
             if (isset($types) && count($types)) {
                 foreach ($types as $id => $name) {
                     $template .= '  <li>';
                     $template .= '   <a href="#" class="type_select dropdown_item" data-field="type" data-item="people" data-item-id="' . $item->id . '" data-value="' . $id . '">';
                     $template .= '    <span class="person-type-' . OutputFilter::stringURLUnicodeSlug($name) . '">' . $name . '</span>';
                     $template .= '   </a>';
                     $template .= '  </li>';
                 }
             }
             $template .= '  </ul>';
             $template .= ' </div>';
             break;
         case 'notes':
             // $template = '<a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_NOTES').'" data-placement="bottom" class="btn" href="#" onclick="Cobalt.openNoteModal('.$item->id.', \'people\');"><i class="glyphicon glyphicon-file"></i></a>';
             $template = '';
             // @TODO: Implement notes modal
             break;
         case 'address':
             $template = $item->work_city . '<br>' . $item->work_state . '<br>' . $item->work_zip . '<br>' . $item->work_country;
             break;
         case 'created':
             $template = DateHelper::formatDate($item->created);
             break;
         case 'modified':
             $template = DateHelper::formatDate($item->modified);
             break;
         default:
             if (isset($column) && isset($item->{$column})) {
                 $template = $item->{$column};
             } else {
                 $template = '';
             }
             break;
     }
     return $template;
 }
Ejemplo n.º 8
0
 /**
  * Prepare HTML field templates for each dataTable column.
  *
  * @param   string column name
  * @param   object of item
  * @return  string HTML template for propper field
  */
 public function getDataTableFieldTemplate($column, $item)
 {
     switch ($column) {
         case 'id':
             $template = '<input type="checkbox" class="export" name="ids[]" value="' . $item->id . '" />';
             break;
         case 'name':
             $template = '<div class="title_holder">';
             $template .= '<a href="' . RouteHelper::_('index.php?view=companies&layout=company&company_id=' . $item->id) . '">' . $item->name . '</a>';
             $template .= '</div>';
             if ($item->address_formatted != '') {
                 $template .= '<address>' . $item->address_formatted . '</address>';
             }
             $template .= '<div class="hidden"><small>' . $item->description . '</small></div>';
             break;
         case 'contact_info':
             $template = $item->phone . '<br>' . $item->email;
             break;
         case 'modified':
             $template = DateHelper::formatDate($item->modified);
             break;
         case 'created':
             $template = DateHelper::formatDate($item->created);
             break;
         case 'action':
             $template = '<div class="btn-group">';
             // @TODO: make these 2 buttons work
             // $template .= ' <a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_CONTACTS').'" data-placement="bottom" class="btn" href="#" onclick="showCompanyContactsDialogModal('.$item->id.')"><i class="glyphicon glyphicon-user"></i></a>';
             // $template .= ' <a rel="tooltip" title="'.TextHelper::_('COBALT_VIEW_NOTES').'" data-placement="bottom" class="btn" href="#" onclick="openNoteModal('.$item->id.',\'company\');"><i class="glyphicon glyphicon-file"></i></a>';
             $template .= '</div>';
             break;
         default:
             if (isset($column) && isset($item->{$column})) {
                 $template = $item->{$column};
             } else {
                 $template = '';
             }
             break;
     }
     return $template;
 }
Ejemplo n.º 9
0
 /**
  * Prepare HTML field templates for each dataTable column.
  *
  * @param   string column name
  * @param   object of item
  * @return  string HTML template for propper field
  */
 public function getDataTableFieldTemplate($column, $item)
 {
     switch ($column) {
         case 'id':
             $template = '<input type="checkbox" class="export" name="ids[]" value="' . $item->id . '" />';
             break;
         case 'type':
             $file_path = sprintf('%s/media/images/%s.png', JPATH_COBALT, $item->filetype);
             if (file_exists($file_path)) {
                 $file_src = sprintf('%s/src/Cobalt/media/images/%s.png', JUri::base(), $item->filetype);
                 $template = '<img src="' . $file_src . '" >';
             } else {
                 $file_src = sprintf('%s/src/Cobalt/media/images/file.png', JUri::base());
                 $template = '<img src="' . $file_src . '" >';
             }
             break;
         case 'name':
             $template = '<div class="dropdown"><span class="caret"></span><a id="' . $item->id . '" class="document_edit dropdown-toggle" data-toggle="dropdown" role="button" href="javascript:void(0);"> ' . $item->name . '</a>';
             $template .= '<ul class="dropdown-menu" role="menu">';
             $template .= '<li><a href="' . RouteHelper::_('index.php?task=PreviewDocument&format=raw&tmpl=component&document=' . $item->filename) . '" target="_blank" class="document_preview" id="preview_' . $item->id . '"><i class="glyphicon glyphicon-eye-open"></i> ' . TextHelper::_('COBALT_PREVIEW') . '</a></li>';
             $template .= '<li><a href="' . RouteHelper::_('index.php?task=DownloadDocument&format=raw&tmpl=component&document=' . $item->filename) . '" target="_blank" class="document_download" id="download_' . $item->id . '"><i class="glyphicon glyphicon-download"></i> ' . TextHelper::_('COBALT_DOWNLOAD') . '</a></li>';
             if ($item->owner_id == UsersHelper::getLoggedInUser()->id) {
                 $template .= '<li><a href="javascript:void(0);" class="document_delete" id="delete_' . $item->id . '"><i class="glyphicon glyphicon-remove"></i> ' . TextHelper::_('COBALT_DELETE') . '</a></li>';
             }
             $template .= '</ul></div>';
             break;
         case 'association':
             $association_type = $item->association_type;
             //assign association link
             switch ($association_type) {
                 case "deal":
                     $view = 'deals';
                     $association_type = "deal";
                     $item->association_name = $item->deal_name;
                     break;
                 case "person":
                     $view = "people";
                     $association_type = "person";
                     $item->association_name = $item->owner_first_name . " " . $item->owner_last_name;
                     break;
                 case "company":
                     $view = "companies";
                     $association_type = "company";
                     $item->association_name = $item->company_name;
                     break;
             }
             if (isset($item->association_name)) {
                 $template = '<a href="' . RouteHelper::_('index.php?view=' . $view . '&layout=' . $association_type . '&id=' . $item->association_id) . '" >' . $item->association_name;
             } else {
                 $template = "";
             }
             break;
         case 'owner':
             $template = $item->owner_name;
             break;
         case 'size':
             $template = FileHelper::sizeFormat($item->size);
             break;
         case 'created':
             $template = DateHelper::formatDate($item->created);
             break;
         case 'modified':
             $template = DateHelper::formatDate($item->modified);
             break;
         default:
             if (isset($column) && isset($item->{$column})) {
                 $template = $item->{$column};
             } else {
                 $template = '';
             }
             break;
     }
     return $template;
 }
Ejemplo n.º 10
0
 public static function getElapsedTime($date, $showDays = TRUE, $showMonths = TRUE, $showYears = TRUE, $showHours = TRUE, $showMinutes = TRUE, $showSeconds = FALSE)
 {
     $time = time() - strtotime($date);
     // to get the time since that moment
     $tokens = array(31536000 => 'year', 2592000 => 'month', 604800 => 'week', 86400 => 'day', 3600 => 'hour', 60 => 'minute', 1 => 'second');
     foreach ($tokens as $unit => $text) {
         if ($time < $unit) {
             continue;
         }
         $numberOfUnits = floor($time / $unit);
         return $numberOfUnits . ' ' . $text . ($numberOfUnits > 1 ? 's' : '');
     }
     return DateHelper::formatDate($date);
 }