コード例 #1
0
ファイル: Raw.php プロジェクト: houzhenggang/cobalt
 public function render($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->type = $app->input->getCmd('type');
     $this->id = $app->input->getInt('id');
     $layout = $this->getLayout();
     $this->format = $app->input->get('format');
     $this->view = $app->input->get('view', 'default');
     switch ($this->type) {
         case 'event':
             $this->var = 'event_id';
             break;
     }
     //retrieve task list from model
     $model = new NoteModel();
     if ($layout == "edit") {
         $notes = $model->getNote($this->id);
     } else {
         $notes = $model->getNotes($this->id, $this->type, false);
     }
     $this->notes = $notes;
     $this->categories = NoteHelper::getCategories();
     //display
     echo parent::render();
 }
コード例 #2
0
ファイル: Html.php プロジェクト: houzhenggang/cobalt
 public function render()
 {
     $app = JFactory::getApplication();
     $type = $app->input->get('type');
     $id = $app->input->get('id');
     $view = $app->input->get('view');
     $document = JFactory::getDocument();
     $document->addScript(JURI::base() . 'src/Cobalt/media/js/cobalt-admin.js');
     //retrieve task list from model
     $model = new NoteModel();
     switch ($view) {
         case "companies":
             $view = "company";
             break;
         case "deals":
             $view = "deal";
             break;
         case "events":
             $view = "event";
             break;
     }
     $notes = $model->getNotes($id, $view, FALSE);
     $this->notes = $notes;
     $this->categories = NoteHelper::getCategories();
     //display
     return parent::render();
 }
コード例 #3
0
ファイル: GetNoteEntry.php プロジェクト: houzhenggang/cobalt
 public function execute()
 {
     $note_id = $this->getInput()->get('note_id');
     $model = new NoteModel();
     $note = $model->getNote($note_id);
     $note_view = ViewHelper::getView('note', 'entry', 'phtml', array('note' => $note[0]));
     echo $note_view->render();
 }
コード例 #4
0
ファイル: GetNoteItem.php プロジェクト: houzhenggang/cobalt
 public function execute()
 {
     $note_id = $this->getInput()->get('note_id');
     $model = new NoteModel();
     $item = $model->getNote($note_id);
     $item[0]['note_id'] = $note_id;
     $response = array('item' => $item[0], 'modal' => array('action' => 'show'));
     echo json_encode($response);
 }
コード例 #5
0
 public function execute()
 {
     //grab people
     $model = new PeopleModel();
     $people = $model->getPeopleList();
     //grab deals
     $model = new DealModel();
     $deals = $model->getDealList();
     //grab notes categories
     $model = new NoteModel();
     $categories = $model->getNoteCategories();
     //construct data obj
     $data = array('people' => $people, 'deals' => $deals, 'categories' => $categories);
     //encode and return results
     echo json_encode($data);
 }
コード例 #6
0
ファイル: Export.php プロジェクト: houzhenggang/cobalt
 /**
  * Get CSV data
  * @param  [type] $data_type [description]
  * @return [type] [description]
  */
 public function getCsvData($data_type)
 {
     $app = \Cobalt\Container::fetch('app');
     $data = array();
     $export_ids = $app->input->get('ids');
     switch ($data_type) {
         case "deals":
             $model = new Deal();
             $data = $model->getDeals($export_ids);
             break;
         case "companies":
             $model = new Company();
             $data = $model->getCompanies($export_ids);
             break;
         case "people":
             $model = new People();
             $data = $model->getPeople($export_ids);
             break;
         case "sales_pipeline":
             $model = new Deal();
             $data = $model->getReportDeals($export_ids);
             break;
         case "source_report":
             $model = new Deal();
             $data = $model->getDeals($export_ids);
             break;
         case "roi_report":
             $model = new Source();
             $data = $model->getRoiSources($export_ids);
             break;
         case "notes":
             $model = new Note();
             $data = $model->getNotes(NULL, NULL, FALSE);
             break;
         case "custom_report":
             $model = new Report();
             $data = $model->getCustomReportData($app->input->get('report_id'));
             break;
     }
     if (count($data)) {
         $header = array_keys((array) $data[0]);
     }
     return array('header' => $header, 'rows' => $data);
 }
コード例 #7
0
ファイル: GetNotes.php プロジェクト: houzhenggang/cobalt
 public function execute()
 {
     $response = array();
     $start = $this->getInput()->getInt('start', 0);
     $limit = $this->getInput()->getInt('limit', 4);
     $object_id = $this->getInput()->getInt('object_id', 0);
     $item_type = $this->getInput()->getCmd('item_type');
     if ($start < 0) {
         $response['alert'] = array('message' => TextHelper::_('COBALT_ERROR_LIMIT_START_SHOULD_BE_POSITIVE'), 'type' => 'error');
     } else {
         if ($limit < 1) {
             $response['alert'] = array('message' => TextHelper::_('COBALT_ERROR_LIMIT_SHOULD_BE_POSITIVE'), 'type' => 'error');
         } else {
             if (empty($item_type)) {
                 $response['alert'] = array('message' => TextHelper::_('COBALT_ERROR_ITEM_TYPE_MUST_BE_NOT_EMPTY'), 'type' => 'error');
             }
         }
     }
     //Always object_id 0 return empty notes
     $load_more = false;
     if ($object_id && !empty($item_type)) {
         $model = new Note();
         $notes = $model->getNotes($object_id, $item_type, false);
         $total = count($notes);
         //filter notes by limits
         $items = array_slice($notes, $start, $limit);
         $view = ViewHelper::getView('note', 'default', 'phtml', array('notes' => $items));
         $load_more = $start + $limit >= $total ? false : true;
         $response['html'] = '';
         foreach ($items as $note) {
             $view = ViewHelper::getView('note', 'entry', 'phtml', array('note' => $note));
             $response['html'] .= $view->render();
         }
     }
     if ($load_more) {
         $response['loadmore'] = array('limit' => count($items) + $limit);
     }
     echo json_encode($response);
 }
コード例 #8
0
ファイル: Deal.php プロジェクト: houzhenggang/cobalt
 public function getDealDetails(&$deal)
 {
     $closed_stages = DealHelper::getClosedStages();
     $deal->closed = in_array($deal->stage_id, $closed_stages) ? TRUE : FALSE;
     $deal_id = $deal->id;
     /** ------------------------------------------
      *  Join contacts
      */
     $peopleModel = new People();
     $peopleModel->set('deal_id', $deal_id);
     $people = $peopleModel->getContacts();
     //assign results to company
     $deal->people = $people;
     /** ------------------------------------------
      *  Join conversations
      */
     $convoModel = new Conversation();
     $convoModel->set('deal_id', $deal_id);
     $conversations = $convoModel->getConversations();
     $deal->conversations = $conversations;
     /** ------------------------------------------
      *  Join notes
      */
     $notesModel = new Note();
     $deal->notes = $notesModel->getNotes($deal_id, 'deal');
     /** ------------------------------------------
      *  Join documents
      */
     $docModel = new Document();
     $docModel->set('deal_id', $deal_id);
     $deal->documents = $docModel->getDocuments();
     /** ------------------------------------------
      *  Join tasks & events
      */
     $eventModel = new Event();
     $eventModel->set('deal_id', $deal_id);
     $events = $eventModel->getEvents();
     $deal->events = $events;
 }
コード例 #9
0
ファイル: Mail.php プロジェクト: houzhenggang/cobalt
 public function saveEmail($email_id = null)
 {
     $app = \Cobalt\Container::fetch('app');
     if (!$email_id) {
         $email_id = $app->input->get('id');
     }
     $email = $this->getEmail($email_id, FALSE);
     $person_id = $app->input->get('person_id');
     $deal_id = $app->input->get('deal_id');
     $person_name = $app->input->get('person_name');
     $deal_name = $app->input->get('deal_name');
     $data = array('deal_id' => $deal_id, 'person_id' => $person_id, 'note' => $email['message'], 'person_name' => $person_name, 'deal_name' => $deal_name);
     $noteModel = new Note();
     $noteModel->store($data);
     $this->_connect();
     if ($person_id) {
         try {
             $this->storeAttachments($email_id, $person_id, "person");
         } catch (\Exception $e) {
         }
     }
     if ($deal_id) {
         try {
             $this->storeAttachments($email_id, $deal_id, "deal");
         } catch (\Exception $e) {
         }
     }
     $this->_delete($email_id);
     $this->_close();
 }
コード例 #10
0
ファイル: Raw.php プロジェクト: houzhenggang/cobalt
 public function _display_notes_filter()
 {
     //get model for reports
     $noteModel = new NoteModel();
     $this->note_entries = $noteModel->getNotes(NULL, NULL, FALSE);
 }
コード例 #11
0
ファイル: Html.php プロジェクト: houzhenggang/cobalt
 public function _display_notes()
 {
     //get model for reports
     $noteModel = new NoteModel();
     $note_entries = $noteModel->getNotes(NULL, NULL, FALSE);
     $this->notes_list = ViewHelper::getView('reports', 'notes_filter', 'phtml', array('note_entries' => $note_entries));
     $state = $noteModel->getState();
     $notes_header = ViewHelper::getView('reports', 'notes_header', 'phtml', array('note_entries' => $note_entries, 'state' => $state));
     $notes_footer = ViewHelper::getView('reports', 'notes_footer', 'phtml');
     $notes_header->team_names = DropdownHelper::getTeamNames();
     $notes_header->user_names = DropdownHelper::getUserNames();
     $notes_header->state = $state;
     $categories = $noteModel->getNoteCategories();
     $notes_header->categories = $categories;
     $notes_header->created_dates = DateHelper::getCreatedDates();
     // Initialise state variables.
     $state = $noteModel->getState();
     //assign refs to view
     $this->notes_header = $notes_header;
     $this->notes_footer = $notes_footer;
     $this->state = $state;
     $this->note_entries = $note_entries;
 }
コード例 #12
0
ファイル: People.php プロジェクト: houzhenggang/cobalt
 public function getPerson($id = null)
 {
     $app = \Cobalt\Container::fetch('app');
     $id = $id ? $id : $app->input->get('id');
     if ($id > 0) {
         $db = JFactory::getDBO();
         //generate query
         //
         $query = $db->getQuery(true);
         $query->select('p.*,c.name as company_name,stat.name as status_name,
                         source.name as source_name, owner.name as owner_name, crmery_user.first_name AS owner_first_name, crmery_user.last_name AS owner_last_name');
         $query->from('#__people AS p');
         $query->leftJoin('#__companies AS c ON c.id = p.company_id AND c.published>0');
         $query->leftJoin('#__people_status AS stat ON stat.id = p.status_id');
         $query->leftJoin('#__sources AS source ON source.id = p.source_id');
         $query->leftJoin('#__users AS owner ON p.owner_id = owner.id');
         $query->leftJoin("#__users AS crmery_user ON crmery_user.id = p.owner_id");
         //searching for specific person
         $query->where("p.published=" . $this->published);
         $query->where("p.id='" . $id . "'");
         //run query and grab results
         $db->setQuery($query);
         $person = $db->loadAssoc();
         /* Deals */
         $dealModel = new Deal();
         $dealModel->set('person_id', $person['id']);
         $person['deals'] = $dealModel->getDeals();
         /* Notes */
         $notesModel = new Note();
         $person['notes'] = $notesModel->getNotes($person['id'], 'person');
         /* Docs */
         $docsModel = new Document();
         $docsModel->set('person_id', $person['id']);
         $person['documents'] = $docsModel->getDocuments();
         /* Tweets */
         if ($person['twitter_user'] != "" && $person['twitter_user'] != " ") {
             $person['tweets'] = TweetsHelper::getTweets($person['twitter_user']);
         }
         $this->person = $person;
     } else {
         //TODO update things to OBJECTS
         $person = (array) new PeopleTable();
         $this->person = $person;
     }
     //$app->triggerEvent('onPersonLoad', array(&$person));
     return $person;
 }
コード例 #13
0
ファイル: Company.php プロジェクト: houzhenggang/cobalt
 public function getCompanies($id = null, $type = null, $user = null, $team = null)
 {
     $app = \Cobalt\Container::fetch('app');
     $this->_id = $id;
     $this->_type = $type;
     $this->_user = $user;
     $this->_team = $team;
     //get query string
     $query = $this->_buildQuery();
     /** ------------------------------------------
      * Set query limits and load results
      */
     if (!TemplateHelper::isMobile()) {
         $limit = $this->getState($this->_view . '_limit');
         $limitStart = $this->getState($this->_view . '_limitstart');
         if (!$this->_id && $limit != 0) {
             if ($limitStart >= $this->getTotal()) {
                 $limitStart = 0;
                 $limit = 10;
                 $limitStart = $limit != 0 ? floor($limitStart / $limit) * $limit : 0;
                 $this->state->set($this->_view . '_limit', $limit);
                 $this->state->set($this->_view . '_limitstart', $limitStart);
             }
             $query .= " LIMIT " . $limit . " OFFSET " . $limitStart;
         }
     }
     //run query and grab results of companies
     $companies = $this->db->setQuery($query)->loadAssocList();
     //generate query to join people
     if (count($companies)) {
         $export = $app->input->get('export');
         if (!$export) {
             foreach ($companies as $key => $company) {
                 /* Tweets */
                 if ($company['twitter_user'] != "" && $company['twitter_user'] != " ") {
                     $companies[$key]['tweets'] = TweetsHelper::getTweets($company['twitter_user']);
                 }
                 //generate people query
                 $peopleModel = new People();
                 $peopleModel->set('company_id', $company['id']);
                 $companies[$key]['people'] = $peopleModel->getContacts();
                 //generate deal query
                 $dealModel = new Deal();
                 $dealModel->set('company_id', $company['id']);
                 $deals = $dealModel->getDeals();
                 $companies[$key]['pipeline'] = 0;
                 $companies[$key]['won_deals'] = 0;
                 for ($i = 0; $i < count($deals); $i++) {
                     $deal = $deals[$i];
                     $companies[$key]['pipeline'] += $deal->amount;
                     if ($deal->percent == 100) {
                         $companies[$key]['won_deals'] += $deal->amount;
                     }
                 }
                 $companies[$key]['deals'] = $deals;
                 //Get Associated Notes
                 $notesModel = new Note();
                 $companies[$key]['notes'] = $notesModel->getNotes($company['id'], 'company');
                 // Get Associated Documents
                 $documentModel = new Document();
                 $documentModel->set('company_id', $company['id']);
                 $companies[$key]['documents'] = $documentModel->getDocuments();
                 $companies[$key]['address_formatted'] = strlen($company['address_1']) > 0 ? $company['address_1'] . $company['address_2'] . ", " . $company['address_city'] . ' ' . $company['address_state'] . ', ' . $company['address_zip'] . ' ' . $company['address_country'] : "";
             }
         }
     }
     //$app->triggerEvent('onCompanyLoad',array(&$companies));
     return $companies;
 }