Esempio n. 1
0
 /**
  * setEmailTemplate load an instance of an email message to be sent or merged
  * Loading the template directly from the database should not be used anymore, its keeped for compatiblity 
  * reason.
  * @usage $emailier->setEmailTempalte(new EmailTemplate("email_template_name"));
  * @param mix sqlConnect $conx connexion to the database thrue an sqlConnect object or an EmailTemplate object.
  * @param string $templatename name of the template to load
  */
 function setEmailTemplate($templatename = "", $conx = null)
 {
     if (is_object($templatename) && (get_class($templatename) == "EmailTemplate" || is_subclass_of($templatename, "EmailTemplate"))) {
         $EmailTemplate = $templatename;
         //echo $EmailTemplate->bodytext;exit;
         $this->setTemplateBodyText($EmailTemplate->bodytext);
         $this->setTemplateBodyHtml($EmailTemplate->bodyhtml);
         $this->setTemplateSubject($EmailTemplate->subject);
         //$this->setBody($EmailTemplate->body);
         //$this->setBodyHtml($EmailTemplate->bodyhtml);
         $this->setFrom($EmailTemplate->senderemail, $EmailTemplate->sendername);
         //$this->setFrom($EmailTemplate->sendername, $EmailTemplate->senderemail);
         $this->setHeader();
         return true;
     } else {
         if (is_null($conx)) {
             $conx = $GLOBALS['conx'];
         }
         $qGetTplt = new sqlQuery($conx);
         $qGetTplt->query('select * from ' . $this->cfgTemplateTable . ' where name=\'' . $templatename . '\'');
         if ($qGetTplt->getNumRows() == 1) {
             $data = $qGetTplt->fetch();
             $this->setTemplateSubject($data->subject);
             $this->setTemplateBodyText($data->bodytext);
             $this->setTemplateBodyHtml($data->bodyhtml);
             $this->setFrom($data->senderemail, $data->sendername);
             $this->setHeader();
             return true;
         } else {
             return false;
         }
     }
     //return $this;
 }
Esempio n. 2
0
 function updatePaymentExtraAmount($idpaylog, $extra_amt, $mode)
 {
     $q = new sqlQuery($this->getDbCon());
     $q_update = new sqlQuery($this->getDbCon());
     $q->query("select * from paymentlog_extra_amount where idpaymentlog = " . $idpaylog);
     if ($q->getNumRows()) {
         $q->fetch();
         $idpaymentlog_extra_amount = $q->getData("idpaymentlog_extra_amount");
         switch ($mode) {
             case 'update':
                 $query = "update paymentlog_extra_amount set extra_amt = " . $extra_amt . " \r\n                                  where idpaymentlog_extra_amount= " . $idpaymentlog_extra_amount;
                 break;
             case 'delete':
                 $query = "delete from paymentlog_extra_amount where \r\n                                  idpaymentlog_extra_amount= " . $idpaymentlog_extra_amount . " Limit 1";
                 break;
         }
     } else {
         switch ($mode) {
             case 'update':
                 $query = "Insert Into paymentlog_extra_amount \r\n                                  (`idpaymentlog`,`extra_amt`,`iduser`)\r\n                                  values (" . $idpaylog . "," . $extra_amt . "," . $_SESSION['do_User']->iduser . ")\r\n                                  ";
                 break;
         }
     }
     $q_update->query($query);
     //echo $query.'<br />';exit;
 }
Esempio n. 3
0
 function isOwner($id)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("Select * from " . $this->table . " where idautoresponder = " . $id . " AND iduser = " . $_SESSION['do_User']->iduser);
     if ($q->getNumRows()) {
         return true;
     } else {
         return false;
     }
 }
 function isTemplateOwner($id)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("select * from " . $this->table . " where " . $this->primary_key . " = " . $id . " AND iduser = " . $_SESSION['do_User']->iduser);
     if ($q->getNumRows()) {
         return true;
     } else {
         return false;
     }
 }
 function isNext($current_idtemplate)
 {
     $q = new sqlQuery($this->getDbCon());
     $sql = "select idmessage,key_name,content,context,can_close,close_duration,plan,language, count(*) as done from {$this->table} where (language='{$this->src_lng}' or language = '{$this->dest_lng}') AND idmessage > {$current_idtemplate}  group by key_name having done = 1 ORDER BY idmessage ASC LIMIT 1";
     $q->query($sql);
     if ($q->getNumRows()) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 6
0
 function isDraftExist($id, $type)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("select * from " . $this->table . " Where id= " . $id . " AND id_type = '" . $type . "' \n                AND iduser = "******"idnote_draft");
     } else {
         return false;
     }
 }
 function isNext($current_idtemplate)
 {
     $q = new sqlQuery($this->getDbCon());
     $sql = "select name, language, count(*) as done from {$this->table} where (language='{$this->src_lng}' or language = '{$this->dest_lng}') AND idemailtemplate > {$current_idtemplate}  group by name having done = 1 ORDER BY idemailtemplate ASC LIMIT 1";
     $q->query($sql);
     if ($q->getNumRows()) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 8
0
 /**
  * Get when the user logged in last time
  * @param integer $iduser 
  * @return idlogin_audit if logged in else return false when the user has never logged in to the system.
  */
 public function getLastLogin($iduser)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("select * from " . $this->table . " where iduser = "******"idlogin_audit");
     } else {
         return false;
     }
 }
 public function getUserIdRegistered($idinvoice, $iduser)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("select * from " . $this->table . " Where idinvoice = " . $idinvoice . " AND iduser = "******"reg_iduser");
     } else {
         return false;
     }
 }
 function has_cc_info($idrecurrent)
 {
     $q = new sqlQuery($this->getDbCon());
     //echo "select * from ".$this->table." where idrecurrentinvoice = ".$idrecurrent;
     $q->query("select * from " . $this->table . " where idrecurrentinvoice = " . $idrecurrent);
     if ($q->getNumRows()) {
         $q->fetch();
         return $q->getData("idrecurrent_invoice_cc");
     } else {
         return false;
     }
 }
Esempio n. 11
0
 public function checkIfInvoiceIsInRecurrent($idinvoice)
 {
     $q = new sqlQuery($this->getDbCon());
     // echo "<br /> select * from ".$this->table." where idinvoice = ".$idinvoice.'<br />';
     $q->query("select * from " . $this->table . " where idinvoice = " . $idinvoice);
     if ($q->getNumRows()) {
         $q->fetch();
         return $q->getData("idrecurrentinvoice");
     } else {
         return false;
     }
 }
Esempio n. 12
0
 /**
  * Method to check if the plugin value is in the table plugin_enable
  * @param String $plugin, the plugin object name
  * @param Integer $iduser
  * @return false if no data found else the query object
  */
 public function isPluginAddedBefore($plugin, $iduser = "")
 {
     if ($iduser == "") {
         $iduser = $_SESSION['do_User']->iduser;
     }
     $q = new sqlQuery($this->getDbCon());
     $q->query("select * from {$this->table} where plugin = '{$plugin}' AND iduser = {$iduser}");
     if ($q->getNumRows() > 0) {
         $q->fetch();
         return $q;
         // return $q->getData("idplugin_enable");
     } else {
         return false;
     }
 }
Esempio n. 13
0
 function isNextUrl($idinvoice)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("select * from " . $this->table . " where idinvoice = " . $idinvoice);
     if ($q->getNumRows()) {
         $q->fetch();
         $next_url = $q->getData("next_url");
         if ($next_url != '' && !empty($next_url)) {
             return $next_url;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Esempio n. 14
0
 function checkIfNotesShared($idcontact = '')
 {
     if (empty($idcontact)) {
         $idcontact = $this->idcontact;
     }
     $q = new sqlQuery($this->getDbCon());
     $q->query("SELECT portal_code FROM contact WHERE idcontact=" . $idcontact . " AND portal_code != ''");
     if ($q->getNumRows()) {
         while ($q->fetch()) {
             $portal_code = $q->getData("portal_code");
             return $portal_code;
         }
     } else {
         return null;
     }
 }
Esempio n. 15
0
 function addUpdateReportData($iduser)
 {
     $do_contact = new Contact();
     $total_contacts = $do_contact->getTotalNumContactsForUser($iduser);
     $do_contact_notes = new ContactNotes();
     $total_notes = $do_contact_notes->getTotalNumContactNotesForUser($iduser);
     $do_contact_projects = new Project();
     $total_projects = $do_contact_projects->getTotalNumProjectsForUser($iduser);
     $do_task = new Task();
     $total_tasks = $do_task->getTotalNumTasksForUser($iduser);
     $do_proj_discussion = new ProjectDiscuss();
     $total_proj_discussions = $do_proj_discussion->getTotalNumProjectDiscussionsForUser($iduser);
     $do_invoice = new Invoice();
     $total_invoices = $do_invoice->getTotalNumInvoicesForUser($iduser);
     //total email sent today
     $msg_con = new sqlQuery($this->getDbCon());
     $sql_msg_check = "SELECT SUM(`num_msg_sent`) AS num_msg_sent  FROM `message_usage` WHERE `iduser` = " . $iduser;
     $msg_con->query($sql_msg_check);
     $total_email_sent = 0;
     if ($msg_con->getNumRows()) {
         $msg_con->fetch();
         $total_email_sent = $msg_con->getData("num_msg_sent");
     }
     $this->getId($iduser);
     if ($this->hasData()) {
         $this->total_contacts = $total_contacts;
         $this->total_notes = $total_notes;
         $this->total_projects = $total_projects;
         $this->total_tasks = $total_tasks;
         $this->total_discussion = $total_proj_discussions;
         $this->total_invoices = $total_invoices;
         $this->current_date = date("Y-m-d");
         $this->total_email_sent = $total_email_sent;
         $this->update();
     } else {
         $this->total_contacts = $total_contacts;
         $this->total_notes = $total_notes;
         $this->total_projects = $total_projects;
         $this->total_tasks = $total_tasks;
         $this->total_discussion = $total_proj_discussions;
         $this->total_invoices = $total_invoices;
         $this->current_date = date("Y-m-d");
         $this->iduser = $iduser;
         $this->total_email_sent = $total_email_sent;
         $this->add();
     }
 }
 function isDiscussionAlertSet($id, $setting_level, $iduser = "")
 {
     if ($iduser == "") {
         $iduser = $_SESSION['do_User']->iduser;
     }
     $q = new sqlQuery($this->getDbCon());
     $q->query("Select iddiscussion_email_setting,discussion_email_alert from " . $this->table . " \n                 Where iduser = "******" AND id = " . $id . " AND setting_level = '" . $setting_level . "'");
     if ($q->getNumRows()) {
         $data = array();
         while ($q->fetch()) {
             $data["iddiscussion_email_setting"] = $q->getData("iddiscussion_email_setting");
             $data["discussion_email_alert"] = $q->getData("discussion_email_alert");
         }
         return $data;
     } else {
         return false;
     }
 }
Esempio n. 17
0
 function getSettingValue($setting_name, $iduser = "")
 {
     if ($iduser == "") {
         $iduser = $_SESSION['do_User']->iduser;
     }
     $q = new sqlQuery($this->getDbCon());
     $q->query("Select iduser_settings,setting_value from " . $this->table . "\n                  where iduser = "******" AND setting_name = '" . $setting_name . "'\n                ");
     if ($q->getNumRows()) {
         $data = array();
         while ($q->fetch()) {
             $data["iduser_settings"] = $q->getData("iduser_settings");
             $data["setting_value"] = $q->getData("setting_value");
         }
         return $data;
     } else {
         return false;
     }
 }
Esempio n. 18
0
 /**
  * LoadEmailer load an instance of an email message to be sent.
  * @param mix sqlConnect $conx connexion to the database thrue an sqlConnect object or an EmailTemplate object.
  * @param string $templatename name of the template to load
  */
 function loadEmailer($conx, $templatename)
 {
     if (get_class($conx) == "EmailTemplate") {
         $EmailTemplate = $conx;
         $this->setSubject($EmailTemplate->subject);
         $this->setBody($EmailTemplate->body);
         $this->setBodyHtml($EmailTemplate->bodyhtml);
         $this->setSender($EmailTemplate->sendername, $EmailTemplate->senderemail);
     } else {
         $qGetTplt = new sqlQuery($conx);
         $qGetTplt->query("select * from {$this->cfgTemplateTable} where name='{$templatename}'");
         if ($qGetTplt->getNumRows() == 1) {
             $data = $qGetTplt->fetch();
             $this->setSubject($data->subject);
             $this->setBody($data->bodytext);
             $this->setBodyHtml($data->bodyhtml);
             $this->setSender($data->sendername, $data->senderemail);
         }
     }
 }
Esempio n. 19
0
 public function checkFileAccessSecurity($filename)
 {
     $return = false;
     /*
       Check if the request is from the Contact Portal and then do the operation
     */
     if ($_SESSION['portal_idcontact'] != '') {
         $do_cnt_note = new ContactNotes();
         if ($do_cnt_note->isDocumentForContact($_SESSION['portal_idcontact'], $filename)) {
             $return = true;
         }
     } elseif ($_SESSION['do_User']->iduser != '') {
         // We have userid set then the request is from a loggedin user
         $q_project_discuss = new sqlQuery($this->getDbCon());
         $q_project_discuss->query("select idproject_task from project_discuss where document = '" . $filename . "'");
         // Check if the file is in project_discuss
         if ($q_project_discuss->getNumRows()) {
             $q_project_discuss->fetch();
             $do_proj_task = new ProjectTask();
             if ($do_proj_task->isProjectTaskReletedToUser($q_project_discuss->getData("idproject_task"), $_SESSION['do_User']->iduser)) {
                 $return = true;
             }
         } else {
             // Not in project Discuss then check in contact_note
             $q_cnt_note = new ContactNotes();
             $q_cnt_note->query("select idcontact from contact_note where document = '" . $filename . "'");
             if ($q_cnt_note->getNumRows()) {
                 $q_cnt_note->fetch();
                 $do_cont = new Contact();
                 if ($do_cont->isContactRelatedToUser($q_cnt_note->getData("idcontact"))) {
                     $return = true;
                 }
             }
         }
     }
     return $return;
 }
Esempio n. 20
0
 /**
  * Determine if tweets should be imported
  */
 function cronFeedStatus($iduser, $tw_friend_id, $tweettime)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("SELECT c.idcontact, cw.idcontact_website FROM contact c INNER JOIN contact_website cw ON c.idcontact = cw.idcontact WHERE c.tw_user_id = " . $tw_friend_id . " AND c.iduser = "******" AND cw.website_type = 'Twitter' AND cw.feed_auto_fetch = 'Yes' AND cw.feed_last_fetch <> '" . $tweettime . "'");
     if ($q->getNumRows()) {
         $q->fetch();
         $idcontact = $q->getData("idcontact");
         $idcontact_website = $q->getData("idcontact_website");
         $q->query("UPDATE contact_website SET feed_last_fetch = '" . $tweettime . "' WHERE idcontact_website = " . $idcontact_website);
         return $idcontact;
     }
     return false;
 }
Esempio n. 21
0
 function insertNoteForAutoFetchOn()
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("SELECT * FROM contact_website WHERE feed_auto_fetch = 'Yes' AND website_type <> 'Twitter'");
     if ($q->getNumRows()) {
         $f_feed = new Feed();
         while ($q->fetch()) {
             $do_contact_note = new ContactNotes($this->getDbCon());
             $this->getId($q->getData("idcontact_website"));
             $do_contact = new Contact();
             $do_contact->getId($this->idcontact);
             //print_r($do_contact);
             //exit;
             if (!$do_contact->hasData()) {
                 continue;
             }
             $do_user = $do_contact->getParentUser();
             if (!$do_user->hasData()) {
                 continue;
             }
             //print_r($do_user);
             //exit;
             $website = $q->getData("website");
             $website = (substr(ltrim($website), 0, 7) != 'http://' ? 'http://' : '') . $website;
             $arr_item = array();
             //try {
             $arr_items = $f_feed->retrieveSinceLastFetch($website, $q->getData("idcontact_website"));
             //}catch(Exception $ex){
             //  $f_feed->turnFeedOff($q->getData("idcontact_website"));
             //}
             if (is_array($arr_items)) {
                 foreach ($arr_items as $arr_item) {
                     if ($q->getData("feed_last_fetch") < $arr_item[1]) {
                         $do_contact_note->idcontact = $q->getData("idcontact");
                         $link = "<br /><a href='" . $website . "' target='_blank'>" . _('Back to the Source of the Article') . "</a><br />";
                         $search = array('<br />', '<br>', '<br >', '<br/>');
                         $replace = "\n";
                         $note_content = $arr_item[0];
                         $note_content = nl2br(strip_tags($note_content));
                         $note_content = preg_replace('/(<br[^>]*>\\s*){2,}/', '<br/>', $note_content);
                         $do_contact_note->note = $note_content . $link;
                         //$do_contact_note->note = nl2br(strip_tags(str_replace($search, $replace, $arr_item[0]))).$link;
                         $do_contact_note->date_added = date('Y-m-d');
                         //$do_contact_note->iduser = $do_contact->getIdUser($q->getData("idcontact"));
                         $do_contact_note->iduser = $do_user->iduser;
                         $do_contact_note->type = 'RSS';
                         //$do_contact_note->iduser = 20;
                         //$do_contact_note->iduser = $_SESSION['do_User']->iduser;
                         $do_contact_note->add();
                         $do_wf_rss_feed_import = new WorkFeedRssFeedImport();
                         $do_wf_rss_feed_import->addRssFeed($do_contact_note, $website, $note_content);
                     }
                 }
             }
             $this->feed_last_fetch = time();
             $this->update();
             //$do_contact_note->free();
         }
     }
 }
Esempio n. 22
0
 /**
  * Function to check the project is already associated with git repository
  * @param idproject
  * @return Git Repository Name
  **/
 function CheckGitProjectExist($idproject)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("SELECT u.git_repo as git_repo,g.idgit_project as idgit_project from git_project g inner join user_gitrepo u on g.iduser_gitrepo=u.iduser_gitrepo where g.idproject='" . $idproject . "'");
     if ($q->getNumRows() >= 1) {
         $data = array();
         while ($q->fetch()) {
             $data['git_repo'] = $q->getData('git_repo');
             $data['idgit_project'] = $q->getData('idgit_project');
         }
         return $data;
     } else {
         return false;
     }
 }
$do_tag = new Tag();
if ($do_tag->isTagValidTagId($idtag) === true) {
    $do_tag->getId($idtag);
    $tag_name = $do_tag->tag_name;
    $do_user = new User();
    $do_user->getId($iduser);
    $user_idcontact = $do_user->idcontact;
    $q_auto_resp = new sqlQuery($GLOBALS['conx']);
    /*$sql_auto_resp = "SELECT ar.name,arem.subject FROM autoresponder AS ar 
       INNER JOIN autoresponder_email AS arem ON ar.idautoresponder = arem.idautoresponder
    		WHERE ar.iduser = {$iduser} AND ar.tag_name = '{$tag_name}'";*/
    $sql_auto_resp = "SELECT `name` FROM autoresponder\n        WHERE iduser = {$iduser} AND tag_name = '{$tag_name}'";
    $q_auto_resp->query($sql_auto_resp);
    $responder = "";
    $resp_email_subj = "";
    if ($q_auto_resp->getNumRows()) {
        $q_auto_resp->fetch();
        $responder = $q_auto_resp->getData("name");
        //$resp_email_subj = $q_auto_resp->getData("subject");
    } else {
        $message = 'already_unsub_from_list';
    }
    $do_cont_note = new ContactNotes();
    $do_cont_note->addNew();
    $do_cont_note->idcontact = $idcontact;
    $do_cont_note->note = $firstname . " " . $lastname . " has unsubscribed from the autoresponder series called " . $responder;
    $do_cont_note->date_added = date("Y-m-d");
    $do_cont_note->iduser = $iduser;
    $do_cont_note->add();
    $do_workfeed_uns = new WorkFeedContactUnsubscibeEmails();
    $do_workfeed_uns->addUnsubscribeEmailWorkfeed($do_cont_note, $responder);
Esempio n. 24
0
 /**
  * Check if the file can be accessed for a project discuss
  * @param $idproject_task -- Int
  * @param $file -- String
  * @return boolean
  */
 function isFilePermitted($idproject_task, $file)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("select idproject_discuss from " . $this->table . " where idproject_task =" . $idproject_task . " AND document ='" . $file . "'");
     //echo "select idproject_discuss from ".$this->table." where idproject_task =".$idproject_task." AND document ='".$file."'";
     if ($q->getNumRows()) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 25
0
 /**
   API usage method for checking duplicate company
   @param iduser,company
 */
 function isDuplicateCompany($iduser, $company)
 {
     $q = new sqlQuery($this->getDbCon());
     $q->query("select * from " . $this->table . " where name = " . trim($company) . " AND iduser = "******"idcompany");
     } else {
         return false;
     }
 }
Esempio n. 26
0
 /**
  * Event method to validate the user info at the time of updatating data
  * @param object $evtcl
  */
 function eventValidationOnUpdate(EventControler $evtcl)
 {
     $fields = $evtcl->fields;
     $do_user_rel = new UserRelations();
     $errorpage = $evtcl->errPage;
     if (trim($fields["firstname"]) == "" || trim($fields["lastname"]) == "" || trim($fields["email"]) == "" || trim($fields["username"]) == "" || trim($fields["password"]) == "" || trim($evtcl->fieldrepeatpass["password"]) == "") {
         $evtcl->doSave = 'No';
         $msg = "You must fill the required fields";
         $errorpage = $evtcl->errorpage;
         $dispError = new Display($errorpage);
         $dispError->addParam("id", $evtcl->id);
         $dispError->addParam("message", $msg);
         $evtcl->setDisplayNext($dispError);
     } elseif (trim($fields["password"]) != trim($evtcl->fieldrepeatpass["password"])) {
         $evtcl->doSave = 'No';
         $msg = "Both the Password are not matching";
         $errorpage = $evtcl->errorpage;
         $dispError = new Display($errorpage);
         $dispError->addParam("id", $evtcl->id);
         $dispError->addParam("message", $msg);
         $evtcl->setDisplayNext($dispError);
     } else {
         $q = new sqlQuery($this->getDbCon());
         $q->query("select * from user where email = '" . trim($fields["email"]) . "' AND iduser <> " . $_SESSION['do_User']->iduser);
         $q1 = new sqlQuery($this->getDbCon());
         $q1->query("select * from user where username = '******'AND iduser <> " . $_SESSION['do_User']->iduser);
         if ($q->getNumRows() > 0 && $_SESSION['do_User']->email != trim($fields["email"])) {
             $evtcl->doSave = 'No';
             $msg = "reg_duplicate_email";
             $dispError = new Display($errorpage);
             $dispError->addParam("message", $msg);
             $evtcl->setDisplayNext($dispError);
         } elseif ($q1->getNumRows() > 0 && $_SESSION['do_User']->username != trim($fields["username"])) {
             $evtcl->doSave = 'No';
             $msg = "Username is already in use";
             $dispError = new Display($errorpage);
             $dispError->addParam("message", $msg);
             $evtcl->setDisplayNext($dispError);
         } else {
             $evtcl->doSave = 'yes';
         }
     }
 }
Esempio n. 27
0
 /**
  * Get the Invoice Totals on on the status and then display with displayInvoiceTotals() with the Year
  * @param $obj -- Object
  * @param $idcontact -- INT
  * @param $idcompany -- INT
  * @return $html_data -- STRING
  */
 function getInvoiceTotals($obj, $idcontact = 0, $idcompany = 0)
 {
     $html_data = '';
     $q = new sqlQuery($this->getDbCon());
     if ($idcontact != 0) {
         $q->query("select distinct(DATE_FORMAT( datecreated,'%Y')) as year_created from invoice where idcontact = " . $idcontact . " AND status <> 'Cancel'");
     } else {
         if ($idcompany != 0) {
             $q->query("select distinct(DATE_FORMAT( datecreated,'%Y')) as year_created from invoice where idcompany = " . $idcompany . " AND status <> 'Cancel'");
         }
     }
     //echo $q->getNumRows();
     if ($q->getNumRows()) {
         while ($q->fetch()) {
             if ($q->getNumRows() == 1 && $q->getData("year_created") == date("Y")) {
                 $html_data .= $this->displayInvoiceTotals($obj, "Quote", $q->getData("year_created"), $idcontact, $idcompany);
                 $html_data .= $this->displayInvoiceTotals($obj, "Invoice", $q->getData("year_created"), $idcontact, $idcompany);
                 $html_data .= $this->displayInvoiceTotals($obj, "Paid", $q->getData("year_created"), $idcontact, $idcompany);
                 $html_data .= $this->displayInvoiceTotals($obj, "Overdue", $q->getData("year_created"), $idcontact, $idcompany);
             } else {
                 $html_data .= '<tr><td  VALIGN="middle"><b>' . $q->getData("year_created") . '</b></td></tr>';
                 $html_data .= $this->displayInvoiceTotals($obj, "Quote", $q->getData("year_created"), $idcontact, $idcompany);
                 $html_data .= $this->displayInvoiceTotals($obj, "Invoice", $q->getData("year_created"), $idcontact, $idcompany);
                 $html_data .= $this->displayInvoiceTotals($obj, "Paid", $q->getData("year_created"), $idcontact, $idcompany);
                 $html_data .= $this->displayInvoiceTotals($obj, "Overdue", $q->getData("year_created"), $idcontact, $idcompany);
             }
         }
     }
     return $html_data;
 }
Esempio n. 28
0
 /** 
  *  eventSendMessage
  *  This will send a message to one or multiple users.
  *  @todo Problem with the getBodyText(true) it returns some bad encoding and no newline, could also be the problem in the template it self...
  */
 function eventSendMessage(EventControler $event_controler)
 {
     $this->setLog("\n eventSendMessage (" . date("Y/m/d H:i:s") . ")");
     if ($event_controler->send == _('Send Mailing')) {
         $email_template = $_SESSION['do_message'];
         $email_template->setApplyFieldFormating(false);
         $this->setLog("\n EmailTemplate id: " . $email_template->getPrimarykeyValue());
         //$this->setLogObject($email_template);
         $this->setLog("\n SQL:" . $this->getSqlQuery());
         $this->query();
         $this->setLog("\n " . $this->getNumRows() . " contacts to send the message");
         while ($this->next()) {
             set_time_limit(500);
             if ($event_controler->unsubtag == 'on') {
                 // set unsubscribe auto-responder list
                 $values_contact = $this->getValues();
                 $tag_values = array("flag" => "unsubscribe_autoresponder", "idtag" => $event_controler->idtag);
                 $values = array_merge($values_contact, $tag_values);
                 $message = $this->sendMessage($email_template, $values);
             } else {
                 $message = $this->sendMessage($email_template, $this->getValues());
             }
             if ($this->last_message_sent) {
                 //$do_contact_notes->iduser = $_SESSION['do_User']->iduser;
                 $do_contact_notes = new ContactNotes();
                 $do_contact_notes->iduser = $_SESSION['do_User']->iduser;
                 //$do_contact_notes->note = '<b>'.$message->getSubject().'</b><br/>'.$message->getBodyText(true);
                 //->getTemplateBodyHtml();
                 $note_text = preg_replace('/^(.*?)<hr>.*$/', '$1', str_replace("\n", '', $message->getBodyHtml(true)));
                 $do_contact_notes->note = '<b>' . $message->getSubject() . '</b><br/>' . $note_text;
                 $do_contact_notes->date_added = date("Y-m-d");
                 $do_contact_notes->idcontact = $this->getPrimaryKeyValue();
                 $do_contact_notes->add();
                 /*
                  * Recording the messages sent by User
                  */
                 $msg_con = new sqlQuery($this->getDbCon());
                 $sql_msg_check = "SELECT * FROM `message_usage` WHERE `iduser` = " . $_SESSION['do_User']->iduser . " AND `date_sent` = '" . date("Y-m-d") . "'";
                 $msg_con->query($sql_msg_check);
                 if ($msg_con->getNumRows()) {
                     $msg_con->fetch();
                     $sql_con_update = new sqlQuery($this->getDbCon());
                     $sql_msg_update = "UPDATE `message_usage` SET `num_msg_sent` = num_msg_sent+1 WHERE `idmessage_usage` = " . $msg_con->getData("idmessage_usage");
                     $sql_con_update->query($sql_msg_update);
                 } else {
                     $sql_con_ins = new sqlQuery($this->getDbCon());
                     $sql_msg_ins = "INSERT INTO `message_usage`(iduser,date_sent,num_msg_sent) VALUES(" . $_SESSION['do_User']->iduser . ",'" . date("Y-m-d") . "',1)";
                     $sql_con_ins->query($sql_msg_ins);
                 }
             }
         }
     } else {
         $event_controler->goto = "contacts.php";
     }
     $this->clearSearch();
     $this->free();
 }
Esempio n. 29
0
 /**
  * createDate
  * static version of getCreateDate
  * @see getCreateDate
  */
 function createDate($tablename, $primary_key_value = 0)
 {
     $q = new sqlQuery($GLOBALS['conx']);
     if (is_object($tablename)) {
         $actual_tablename = $tablename->getTable();
         $primary_key_value = $tablename->getPrimaryKeyValue();
     } else {
         $actual_tablename = $tablename;
     }
     $q->query("SELECT created_date FROM `" . $this->getTable() . "` WHERE \n                   `table_name`='" . $q->quote($actual_tablename) . "' AND \n                   `id`='" . $q->quote($primary_key_value) . "'");
     if ($q->getNumRows() > 0) {
         return $q->getData("created_date");
     } else {
         return false;
     }
     $q->free();
 }
Esempio n. 30
0
 /**
  * Function to update the contact tables for the co-workers at the time of contact merging if the contacts are shared
  * @param integer $id_to_keep 
  * @param integer $contact_id_del
  */
 function resetContactSharingOnMerging($id_to_keep, $contact_id_del)
 {
     $q = new sqlQuery($this->getDbCon());
     $q_update = new sqlQuery($this->getDbCon());
     $q->query("select * from " . $this->table . " where iduser = "******" AND idcontact = " . $contact_id_del);
     if ($q->getNumRows() > 0) {
         while ($q->fetch()) {
             $q_update->query("update " . $this->table . " set idcontact = " . $id_to_keep . " where idcontact_sharing   = " . $q->getData("idcontact_sharing") . " Limit 1");
             $co_worker_view = "userid" . $q->getData("idcoworker") . "_contact";
             $q_update->query("update " . $co_worker_view . " set idcontact = " . $id_to_keep . " where idcontact   = " . $contact_id_del);
         }
     }
 }