コード例 #1
0
 public function handleEvent($handlerType, $entityData)
 {
     global $log, $adb;
     $moduleName = $entityData->getModuleName();
     if ($moduleName == 'SalesOrder') {
         $soId = $entityData->getId();
         $data = $entityData->getData();
         if ($data['enable_recurring'] == 'on' || $data['enable_recurring'] == 1) {
             $frequency = $data['recurring_frequency'];
             $startPeriod = getDBInsertDateValue($data['start_period']);
             $endPeriod = getDBInsertDateValue($data['end_period']);
             $paymentDuration = $data['payment_duration'];
             $invoiceStatus = $data['invoicestatus'];
             if (isset($frequency) && $frequency != '' && $frequency != '--None--') {
                 $check_query = "SELECT * FROM vtiger_invoice_recurring_info WHERE salesorderid=?";
                 $check_res = $adb->pquery($check_query, array($soId));
                 $noofrows = $adb->num_rows($check_res);
                 if ($noofrows > 0) {
                     $row = $adb->query_result_rowdata($check_res, 0);
                     $query = "UPDATE vtiger_invoice_recurring_info SET recurring_frequency=?, start_period=?, end_period=?, payment_duration=?, invoice_status=? WHERE salesorderid=?";
                     $params = array($frequency, $startPeriod, $endPeriod, $paymentDuration, $invoiceStatus, $soId);
                 } else {
                     $query = "INSERT INTO vtiger_invoice_recurring_info VALUES (?,?,?,?,?,?,?)";
                     $params = array($soId, $frequency, $startPeriod, $endPeriod, $startPeriod, $paymentDuration, $invoiceStatus);
                 }
                 $adb->pquery($query, $params);
             }
         } else {
             $query = "DELETE FROM vtiger_invoice_recurring_info WHERE salesorderid = ?";
             $adb->pquery($query, array($soId));
         }
     }
 }
コード例 #2
0
ファイル: savetask.php プロジェクト: hardikk/HNH
function vtSaveTask($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("savetask");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $tm = new VTTaskManager($adb);
    if (isset($request["task_id"])) {
        $task = $tm->retrieveTask($request["task_id"]);
    } else {
        $taskType = $request["task_type"];
        $workflowId = $request["workflow_id"];
        $task = $tm->createTask($taskType, $workflowId);
    }
    $task->summary = $request["summary"];
    if ($request["active"] == "true") {
        $task->active = true;
    } else {
        if ($request["active"] == "false") {
            $task->active = false;
        }
    }
    if (isset($request['check_select_date'])) {
        $trigger = array('days' => ($request['select_date_direction'] == 'after' ? 1 : -1) * (int) $request['select_date_days'], 'field' => $request['select_date_field']);
        $task->trigger = $trigger;
    }
    $fieldNames = $task->getFieldNames();
    foreach ($fieldNames as $fieldName) {
        $task->{$fieldName} = $request[$fieldName];
        if ($fieldName == 'calendar_repeat_limit_date') {
            $task->{$fieldName} = getDBInsertDateValue($request[$fieldName]);
        }
    }
    $tm->saveTask($task);
    if (isset($request["return_url"])) {
        $returnUrl = $request["return_url"];
    } else {
        $returnUrl = $module->editTaskUrl($task->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}
コード例 #3
0
ファイル: thunderbirdplugin.php プロジェクト: hardikk/HNH
function track_email($user_name, $password, $contact_ids, $date_sent, $email_subject, $email_body)
{
    if (authentication($user_name, $password)) {
        global $current_user;
        global $adb;
        global $log;
        require_once 'modules/Users/Users.php';
        require_once 'modules/Emails/Emails.php';
        $current_user = new Users();
        $user_id = $current_user->retrieve_user_id($user_name);
        $query = "select email1 from vtiger_users where id =?";
        $result = $adb->pquery($query, array($user_id));
        $user_emailid = $adb->query_result($result, 0, "email1");
        $current_user = $current_user->retrieveCurrentUserInfoFromFile($user_id);
        $email = new Emails();
        //$log->debug($msgdtls['contactid']);
        $emailbody = str_replace("'", "''", $email_body);
        $emailsubject = str_replace("'", "''", $email_subject);
        $datesent = substr($date_sent, 1, 10);
        $mydate = date('Y-m-d', $datesent);
        $mydate = getDBInsertDateValue($mydate);
        $email->column_fields[subject] = $emailsubject;
        $email->column_fields[assigned_user_id] = $user_id;
        $email->column_fields[date_start] = $mydate;
        $email->column_fields[description] = $emailbody;
        $email->column_fields[activitytype] = 'Emails';
        $email->plugin_save = true;
        $email->save("Emails");
        $query = "select fieldid from vtiger_field where fieldname = 'email' and tabid = 4 and vtiger_field.presence in (0,2)";
        $result = $adb->pquery($query, array());
        $field_id = $adb->query_result($result, 0, "fieldid");
        $email->set_emails_contact_invitee_relationship($email->id, $contact_ids);
        $email->set_emails_se_invitee_relationship($email->id, $contact_ids);
        $email->set_emails_user_invitee_relationship($email->id, $user_id);
        $sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid=?";
        $result = $adb->pquery($sql, array($contact_ids));
        $camodulerow = $adb->fetch_array($result);
        if (isset($camodulerow)) {
            $emailid = $camodulerow["email"];
            //added to save < as $lt; and > as &gt; in the database so as to retrive the emailID
            $user_emailid = str_replace('<', '&lt;', $user_emailid);
            $user_emailid = str_replace('>', '&gt;', $user_emailid);
            $query = 'insert into vtiger_emaildetails values (?,?,?,?,?,?,?,?)';
            $params = array($email->id, $emailid, $user_emailid, "", "", "", $user_id . '@-1|' . $contact_ids . '@' . $field_id . '|', "THUNDERBIRD");
            $adb->pquery($query, $params);
        }
        return $email->id;
    }
}
コード例 #4
0
ファイル: RecurringType.php プロジェクト: latechdirect/vtiger
 /**
  * Constructor for class RecurringType
  * @param array  $repeat_arr     - array contains recurring info
  */
 function RecurringType($repeat_arr)
 {
     //to get startdate and enddate in yyyy-mm-dd format
     $st_date = explode("-", getDBInsertDateValue($repeat_arr["startdate"]));
     $end_date = explode("-", getDBInsertDateValue($repeat_arr["enddate"]));
     $start_date = array('day' => $st_date[2], 'month' => $st_date[1], 'year' => $st_date[0]);
     $end_date = array('day' => $end_date[2], 'month' => $end_date[1], 'year' => $end_date[0]);
     $this->recur_type = $repeat_arr['type'];
     $this->recur_freq = $repeat_arr['repeat_frequency'];
     $this->startdate = new vt_DateTime($start_date, true);
     $this->enddate = new vt_DateTime($end_date, true);
     if ($repeat_arr['sun_flag']) {
         $this->dayofweek_to_rpt[] = 0;
     }
     if ($repeat_arr['mon_flag']) {
         $this->dayofweek_to_rpt[] = 1;
     }
     if ($repeat_arr['tue_flag']) {
         $this->dayofweek_to_rpt[] = 2;
     }
     if ($repeat_arr['wed_flag']) {
         $this->dayofweek_to_rpt[] = 3;
     }
     if ($repeat_arr['thu_flag']) {
         $this->dayofweek_to_rpt[] = 4;
     }
     if ($repeat_arr['fri_flag']) {
         $this->dayofweek_to_rpt[] = 5;
     }
     if ($repeat_arr['sat_flag']) {
         $this->dayofweek_to_rpt[] = 6;
     }
     $this->repeat_monthby = $repeat_arr['repeatmonth_type'];
     if (isset($repeat_arr['repeatmonth_date'])) {
         $this->rptmonth_datevalue = $repeat_arr['repeatmonth_date'];
     }
     $this->rptmonth_daytype = $repeat_arr['repeatmonth_daytype'];
     $this->recurringdates = $this->getRecurringDates();
 }
コード例 #5
0
ファイル: Save.php プロジェクト: vtiger-jp/vtigercrm-5.1.x-ja
             $log->info("CustomView :: Save :: vtiger_cvcolumnlist update successfully" . $genCVid);
             if ($std_filter_list["columnname"] != "") {
                 $stdfiltersql = "INSERT INTO vtiger_cvstdfilter (cvid,columnname,stdfilter,startdate,enddate) VALUES (?,?,?,?,?)";
                 $stdfilterparams = array($genCVid, $std_filter_list["columnname"], $std_filter_list["stdfilter"], $adb->formatDate($std_filter_list["startdate"], true), $adb->formatDate($std_filter_list["enddate"], true));
                 $stdfilterresult = $adb->pquery($stdfiltersql, $stdfilterparams);
                 $log->info("CustomView :: Save :: vtiger_cvstdfilter update successfully" . $genCVid);
             }
             for ($i = 0; $i < count($adv_filter_col); $i++) {
                 $col = explode(":", $adv_filter_col[$i]);
                 $temp_val = explode(",", $adv_filter_value[$i]);
                 if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') {
                     $val = array();
                     for ($x = 0; $x < count($temp_val); $x++) {
                         //if date and time given then we have to convert the date and leave the time as it is, if date only given then temp_time value will be empty
                         list($temp_date, $temp_time) = explode(" ", $temp_val[$x]);
                         $temp_date = getDBInsertDateValue(trim($temp_date));
                         if (trim($temp_time) != '') {
                             $temp_date .= ' ' . $temp_time;
                         }
                         $val[$x] = $temp_date;
                     }
                     $adv_filter_value[$i] = implode(", ", $val);
                 }
                 $advfiltersql = "INSERT INTO vtiger_cvadvfilter (cvid,columnindex,columnname,comparator,value) VALUES (?,?,?,?,?)";
                 $advfilterparams = array($genCVid, $i, $adv_filter_col[$i], $adv_filter_option[$i], $adv_filter_value[$i]);
                 $advfilterresult = $adb->pquery($advfiltersql, $advfilterparams);
             }
             $log->info("CustomView :: Save :: vtiger_cvadvfilter update successfully" . $cvid);
         }
     }
 }
コード例 #6
0
/** Function to set date values compatible to database (YY_MM_DD)
 * @param $value -- value :: Type string
 * @returns $insert_date -- insert_date :: Type string
 */
function getValidDBInsertDateValue($value)
{
    global $log;
    $log->debug("Entering getDBInsertDateValue(" . $value . ") method ...");
    global $current_user;
    list($y, $m, $d) = split('-', $value);
    if (strlen($y) < 4) {
        $insert_date = getDBInsertDateValue($value);
    } else {
        $insert_date = $value;
    }
    $log->debug("Exiting getDBInsertDateValue method ...");
    return $insert_date;
}
コード例 #7
0
ファイル: CreateXL.php プロジェクト: hardikk/HNH
$workbook =& new writeexcel_workbook($fname);
$worksheet =& $workbook->addworksheet();
# Set the column width for columns 1, 2, 3 and 4
$worksheet->set_column(0, 3, 15);
# Create a format for the column headings
$header =& $workbook->addformat();
$header->set_bold();
$header->set_size(12);
$header->set_color('blue');
# Write out the data
$reportid = vtlib_purify($_REQUEST["record"]);
$oReport = new Reports($reportid);
$filtercolumn = $_REQUEST['stdDateFilterField'];
$filter = $_REQUEST['stdDateFilter'];
$startdate = getDBInsertDateValue($_REQUEST['startdate']);
$enddate = getDBInsertDateValue($_REQUEST['enddate']);
$oReportRun = new ReportRun($reportid);
$filterlist = $oReportRun->RunTimeFilter($filtercolumn, $filter, $startdate, $enddate);
$arr_val = $oReportRun->GenerateReport("PDF", $filterlist);
$totalxls = $oReportRun->GenerateReport("TOTALXLS", $filterlist);
if (isset($arr_val)) {
    foreach ($arr_val[0] as $key => $value) {
        $worksheet->write(0, $count, $key, $header);
        $count = $count + 1;
    }
    $rowcount = 1;
    foreach ($arr_val as $key => $array_value) {
        $dcount = 0;
        foreach ($array_value as $hdr => $value) {
            //$worksheet->write($key+1, $dcount, iconv("UTF-8", "ISO-8859-1", $value));
            $value = decode_html($value);
コード例 #8
0
    $this->Write(5,$txt,$URL);
    $this->SetStyle('U',false);
    $this->SetTextColor(0);
}

}//end of class
*/
$reportid = vtlib_purify($_REQUEST["record"]);
$oReport = new Reports($reportid);
//Code given by Csar Rodrguez for Rwport Filter
$filtercolumn = $_REQUEST["stdDateFilterField"];
$filter = $_REQUEST["stdDateFilter"];
$oReportRun = new ReportRun($reportid);
$startdate = getDBInsertDateValue($_REQUEST["startdate"]);
//Convert the user date format to DB date format
$enddate = getDBInsertDateValue($_REQUEST["enddate"]);
//Convert the user date format to DB date format
$filterlist = $oReportRun->RunTimeFilter($filtercolumn, $filter, $startdate, $enddate);
$arr_val = $oReportRun->GenerateReport("PDF", $filterlist);
if (isset($arr_val)) {
    foreach ($arr_val as $wkey => $warray_value) {
        foreach ($warray_value as $whd => $wvalue) {
            if (strlen($wvalue) < strlen($whd)) {
                $w_inner_array[] = strlen($whd);
            } else {
                $w_inner_array[] = strlen($wvalue);
            }
        }
        $warr_val[] = $w_inner_array;
        unset($w_inner_array);
    }
コード例 #9
0
 /** Function to insert values in the specifed table for the specified module
  * @param $table_name -- table name:: Type varchar
  * @param $module -- module:: Type varchar
  */
 function insertIntoEntityTable($table_name, $module, $fileid = '')
 {
     global $log;
     global $current_user, $app_strings;
     $log->info("function insertIntoEntityTable " . $module . ' vtiger_table name ' . $table_name);
     global $adb;
     $insertion_mode = $this->mode;
     //Checkin whether an entry is already is present in the vtiger_table to update
     if ($insertion_mode == 'edit') {
         $tablekey = $this->tab_name_index[$table_name];
         // Make selection on the primary key of the module table to check.
         $check_query = "select {$tablekey} from {$table_name} where {$tablekey}=?";
         $check_result = $adb->pquery($check_query, array($this->id));
         $num_rows = $adb->num_rows($check_result);
         if ($num_rows <= 0) {
             $insertion_mode = '';
         }
     }
     $tabid = getTabid($module);
     if ($module == 'Calendar' && $this->column_fields["activitytype"] != null && $this->column_fields["activitytype"] != 'Task') {
         $tabid = getTabid('Events');
     }
     if ($insertion_mode == 'edit') {
         $update = array();
         $update_params = array();
         require 'user_privileges/user_privileges_' . $current_user->id . '.php';
         if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
             $sql = "select * from vtiger_field where tabid in (" . generateQuestionMarks($tabid) . ") and tablename=? and displaytype in (1,3) and presence in (0,2) group by columnname";
             $params = array($tabid, $table_name);
         } else {
             $profileList = getCurrentUserProfileList();
             if (count($profileList) > 0) {
                 $sql = "SELECT *\n\t\t\t  \t\t\tFROM vtiger_field\n\t\t\t  \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t  \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t  \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t  \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t  \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t  \t\t\tAND vtiger_profile2field.visible = 0 \n\t\t\t  \t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\n\t\t\t  \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname";
                 $params = array($tabid, $profileList, $table_name);
             } else {
                 $sql = "SELECT *\n\t\t\t  \t\t\tFROM vtiger_field\n\t\t\t  \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t  \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t  \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t  \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t  \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t  \t\t\tAND vtiger_profile2field.visible = 0 \n\t\t\t  \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname";
                 $params = array($tabid, $table_name);
             }
         }
     } else {
         $table_index_column = $this->tab_name_index[$table_name];
         if ($table_index_column == 'id' && $table_name == 'vtiger_users') {
             $currentuser_id = $adb->getUniqueID("vtiger_users");
             $this->id = $currentuser_id;
         }
         $column = array($table_index_column);
         $value = array($this->id);
         $sql = "select * from vtiger_field where tabid=? and tablename=? and displaytype in (1,3,4) and vtiger_field.presence in (0,2)";
         $params = array($tabid, $table_name);
     }
     $result = $adb->pquery($sql, $params);
     $noofrows = $adb->num_rows($result);
     for ($i = 0; $i < $noofrows; $i++) {
         $fieldname = $adb->query_result($result, $i, "fieldname");
         $columname = $adb->query_result($result, $i, "columnname");
         $uitype = $adb->query_result($result, $i, "uitype");
         $generatedtype = $adb->query_result($result, $i, "generatedtype");
         $typeofdata = $adb->query_result($result, $i, "typeofdata");
         $typeofdata_array = explode("~", $typeofdata);
         $datatype = $typeofdata_array[0];
         if ($uitype == 4 && $insertion_mode != 'edit') {
             $this->column_fields[$fieldname] = $this->setModuleSeqNumber("increment", $module);
             $fldvalue = $this->column_fields[$fieldname];
         }
         if (isset($this->column_fields[$fieldname])) {
             if ($uitype == 56) {
                 if ($this->column_fields[$fieldname] == 'on' || $this->column_fields[$fieldname] == 1) {
                     $fldvalue = '1';
                 } else {
                     $fldvalue = '0';
                 }
             } elseif ($uitype == 15 || $uitype == 16) {
                 if ($this->column_fields[$fieldname] == $app_strings['LBL_NOT_ACCESSIBLE']) {
                     //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value.
                     $sql = "select {$columname} from  {$table_name} where " . $this->tab_name_index[$table_name] . "=?";
                     $res = $adb->pquery($sql, array($this->id));
                     $pick_val = $adb->query_result($res, 0, $columname);
                     $fldvalue = $pick_val;
                 } else {
                     $fldvalue = $this->column_fields[$fieldname];
                 }
             } elseif ($uitype == 33) {
                 if (is_array($this->column_fields[$fieldname])) {
                     $field_list = implode(' |##| ', $this->column_fields[$fieldname]);
                 } else {
                     $field_list = $this->column_fields[$fieldname];
                 }
                 $fldvalue = $field_list;
             } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23) {
                 if ($_REQUEST['action'] == 'Import') {
                     $fldvalue = $this->column_fields[$fieldname];
                 } else {
                     //Added to avoid function call getDBInsertDateValue in ajax save
                     if (isset($current_user->date_format)) {
                         $fldvalue = getValidDBInsertDateValue($this->column_fields[$fieldname]);
                     } else {
                         $fldvalue = $this->column_fields[$fieldname];
                     }
                 }
             } elseif ($uitype == 7) {
                 //strip out the spaces and commas in numbers if given ie., in amounts there may be ,
                 $fldvalue = str_replace(",", "", $this->column_fields[$fieldname]);
                 //trim($this->column_fields[$fieldname],",");
             } elseif ($uitype == 26) {
                 if (empty($this->column_fields[$fieldname])) {
                     $fldvalue = 1;
                     //the documents will stored in default folder
                 } else {
                     $fldvalue = $this->column_fields[$fieldname];
                 }
             } elseif ($uitype == 28) {
                 if ($this->column_fields[$fieldname] == null) {
                     $fileQuery = $adb->pquery("SELECT filename from vtiger_notes WHERE notesid = ?", array($this->id));
                     $fldvalue = null;
                     if (isset($fileQuery)) {
                         $rowCount = $adb->num_rows($fileQuery);
                         if ($rowCount > 0) {
                             $fldvalue = $adb->query_result($fileQuery, 0, 'filename');
                         }
                     }
                 } else {
                     $fldvalue = $this->column_fields[$fieldname];
                 }
             } elseif ($uitype == 8) {
                 $this->column_fields[$fieldname] = rtrim($this->column_fields[$fieldname], ',');
                 $ids = explode(',', $this->column_fields[$fieldname]);
                 $json = new Zend_Json();
                 $fldvalue = $json->encode($ids);
             } elseif ($uitype == 12) {
                 $query = "SELECT email1 FROM vtiger_users WHERE id = ?";
                 $res = $adb->pquery($query, array($current_user->id));
                 $rows = $adb->num_rows($res);
                 if ($rows > 0) {
                     $fldvalue = $adb->query_result($res, 0, 'email1');
                 }
             } elseif ($uitype == 71 && $generatedtype == 2) {
                 // Convert currency to base currency value before saving for custom fields of type currency
                 $currency_id = $current_user->currency_id;
                 $curSymCrate = getCurrencySymbolandCRate($currency_id);
                 $fldvalue = convertToDollar($this->column_fields[$fieldname], $curSymCrate['rate']);
             } else {
                 $fldvalue = $this->column_fields[$fieldname];
             }
             if ($uitype != 33 && $uitype != 8) {
                 $fldvalue = from_html($fldvalue, $insertion_mode == 'edit' ? true : false);
             }
         } else {
             $fldvalue = '';
         }
         if ($fldvalue == '') {
             $fldvalue = $this->get_column_value($columname, $fldvalue, $fieldname, $uitype, $datatype);
         }
         if ($insertion_mode == 'edit') {
             if ($table_name != 'vtiger_ticketcomments' && $uitype != 4) {
                 array_push($update, $columname . "=?");
                 array_push($update_params, $fldvalue);
             }
         } else {
             array_push($column, $columname);
             array_push($value, $fldvalue);
         }
     }
     if ($insertion_mode == 'edit') {
         if ($_REQUEST['module'] == 'Potentials') {
             $dbquery = 'select sales_stage from vtiger_potential where potentialid = ?';
             $sales_stage = $adb->query_result($adb->pquery($dbquery, array($this->id)), 0, 'sales_stage');
             if ($sales_stage != $_REQUEST['sales_stage'] && $_REQUEST['sales_stage'] != '') {
                 $date_var = date('YmdHis');
                 $closingdate = $_REQUEST['ajxaction'] == 'DETAILVIEW' ? $this->column_fields['closingdate'] : getDBInsertDateValue($this->column_fields['closingdate']);
                 $sql = "insert into vtiger_potstagehistory values(?,?,?,?,?,?,?,?)";
                 $params = array('', $this->id, $this->column_fields['amount'], decode_html($sales_stage), $this->column_fields['probability'], 0, $adb->formatDate($closingdate, true), $adb->formatDate($date_var, true));
                 $adb->pquery($sql, $params);
             }
         } elseif ($_REQUEST['module'] == 'PurchaseOrder' || $_REQUEST['module'] == 'SalesOrder' || $_REQUEST['module'] == 'Quotes' || $_REQUEST['module'] == 'Invoice') {
             //added to update the history for PO, SO, Quotes and Invoice
             $history_field_array = array("PurchaseOrder" => "postatus", "SalesOrder" => "sostatus", "Quotes" => "quotestage", "Invoice" => "invoicestatus");
             $inventory_module = $_REQUEST['module'];
             if ($_REQUEST['ajxaction'] == 'DETAILVIEW') {
                 if ($inventory_module == "PurchaseOrder") {
                     $relatedname = getVendorName($this->column_fields['vendor_id']);
                 } else {
                     $relatedname = getAccountName($this->column_fields['account_id']);
                 }
                 $total = $this->column_fields['hdnGrandTotal'];
             } else {
                 if ($inventory_module == "PurchaseOrder") {
                     $relatedname = $_REQUEST["vendor_name"];
                 } else {
                     $relatedname = $_REQUEST["account_name"];
                 }
                 $total = $_REQUEST['total'];
             }
             if ($this->column_fields["{$history_field_array[$inventory_module]}"] == $app_strings['LBL_NOT_ACCESSIBLE']) {
                 //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value.
                 $his_col = $history_field_array[$inventory_module];
                 $his_sql = "select {$his_col} from  {$this->table_name} where " . $this->table_index . "=?";
                 $his_res = $adb->pquery($his_sql, array($this->id));
                 $status_value = $adb->query_result($his_res, 0, $his_col);
                 $stat_value = $status_value;
             } else {
                 $stat_value = $this->column_fields["{$history_field_array[$inventory_module]}"];
             }
             $oldvalue = getSingleFieldValue($this->table_name, $history_field_array[$inventory_module], $this->table_index, $this->id);
             if ($this->column_fields["{$history_field_array[$inventory_module]}"] != '' && $oldvalue != $stat_value) {
                 addInventoryHistory($inventory_module, $this->id, $relatedname, $total, $stat_value);
             }
         }
         //Check done by Don. If update is empty the the query fails
         if (count($update) > 0) {
             $sql1 = "update {$table_name} set " . implode(",", $update) . " where " . $this->tab_name_index[$table_name] . "=?";
             array_push($update_params, $this->id);
             $adb->pquery($sql1, $update_params);
         }
     } else {
         $sql1 = "insert into {$table_name}(" . implode(",", $column) . ") values(" . generateQuestionMarks($value) . ")";
         $adb->pquery($sql1, $value);
     }
 }
コード例 #10
0
        $focus->retrieve_entity_info($_REQUEST['record'], "SalesOrder");
        $focus->name = $focus->column_fields['subject'];
    }
} else {
    if (isset($_REQUEST['convertmode']) && $_REQUEST['convertmode'] == 'update_quote_val') {
        //Updating the Select Quote Value in Create Mode
        foreach ($focus->column_fields as $fieldname => $val) {
            if (isset($_REQUEST[$fieldname])) {
                $value = $_REQUEST[$fieldname];
                $focus->column_fields[$fieldname] = $value;
            }
        }
        //Handling for dateformat in due_date vtiger_field
        if ($focus->column_fields['duedate'] != '') {
            $curr_due_date = $focus->column_fields['duedate'];
            $focus->column_fields['duedate'] = getDBInsertDateValue($curr_due_date);
        }
        $quoteid = $focus->column_fields['quote_id'];
        $quote_focus = new Quotes();
        $quote_focus->id = $quoteid;
        $quote_focus->retrieve_entity_info($quoteid, "Quotes");
        $focus = getConvertQuoteToSoObject($focus, $quote_focus, $quoteid);
        // Reset the value w.r.t Quote Selected
        $currencyid = $quote_focus->column_fields['currency_id'];
        $rate = $quote_focus->column_fields['conversion_rate'];
        //Added to display the Quotes's associated vtiger_products -- when we select Quote in New SO page
        if (isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') {
            $associated_prod = getAssociatedProducts("Quotes", $quote_focus, $focus->column_fields['quote_id']);
        }
        $smarty->assign("QUOTE_ID", $focus->column_fields['quote_id']);
        $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
コード例 #11
0
 /**
  * Repeat Activity instance till given limit.
  */
 static function repeat($focus)
 {
     global $log;
     $repeat = getrecurringObjValue();
     $frequency = $repeat->recur_freq;
     $repeattype = $repeat->recur_type;
     $base_focus = new Activity();
     $base_focus->retrieve_entity_info($focus->id, 'Events');
     $base_focus->id = $_REQUEST['record'];
     $base_focus_start = $base_focus->column_fields['date_start'] . ' ' . $base_focus->column_fields['time_start'];
     $base_focus_end = $base_focus->column_fields['due_date'] . ' ' . $base_focus->column_fields['time_end'];
     $repeat_limit = getDBInsertDateValue($_REQUEST['calendar_repeat_limit_date']) . ' ' . $base_focus->column_fields['time_start'];
     $repeatIntervals = self::getRepeatInterval($repeattype, $frequency, $repeat, $base_focus_start, $repeat_limit);
     $base_focus_start = self::mktime($base_focus_start);
     $base_focus_end = self::mktime($base_focus_end);
     $skip_focus_fields = array('record_id', 'createdtime', 'modifiedtime', 'recurringtype');
     /** Create instance before and reuse */
     $new_focus = new Activity();
     foreach ($repeatIntervals as $interval) {
         $new_focus_start_timing = self::nexttime($base_focus_start, "+{$interval} days");
         $new_focus_start_timing = self::splittime(self::formattime($new_focus_start_timing));
         $new_focus_end_timing = self::nexttime($base_focus_end, "+{$interval} days");
         $new_focus_end_timing = self::splittime(self::formattime($new_focus_end_timing));
         // Reset the new_focus and prepare for reuse
         if (isset($new_focus->id)) {
             unset($new_focus->id);
         }
         foreach ($new_focus->column_fields as $key => $value) {
             $new_focus->column_fields[$key] = '';
         }
         foreach ($base_focus->column_fields as $key => $value) {
             if (in_array($key, $skip_focus_fields)) {
                 // skip copying few fields
             } else {
                 if ($key == 'date_start') {
                     $new_focus->column_fields['date_start'] = $new_focus_start_timing[0];
                 } else {
                     if ($key == 'time_start') {
                         $new_focus->column_fields['time_start'] = $new_focus_start_timing[1];
                     } else {
                         if ($key == 'time_end') {
                             $new_focus->column_fields['time_end'] = $new_focus_end_timing[1];
                         } else {
                             if ($key == 'due_date') {
                                 $new_focus->column_fields['due_date'] = $new_focus_end_timing[0];
                             } else {
                                 $new_focus->column_fields[$key] = $value;
                             }
                         }
                     }
                 }
             }
         }
         $new_focus->save('Calendar');
     }
 }
コード例 #12
0
/**
 * Function to status availability of user
 * @param string     $owner                   -   ownername
 * @param integer    $userid                  -   userid
 * @param integer    $activity_id             -   activityid
 * @param string     $avail_date              -   date in string format
 * @param string     $activity_start_time     -   time string 
 * @param string     $activity_end_time       -   time string 
 * return string     $availability            -   html img tag in string
 */
function status_availability($owner, $userid, $activity_id, $avail_date, $activity_start_time, $activity_end_time)
{
    global $adb, $image_path, $log, $theme;
    $log->debug("Entering status_availability(" . $owner, $userid . "," . $activity_id . "," . $avail_date . "," . $activity_start_time . "," . $activity_end_time . ") method ...");
    $avail_flag = "false";
    $avail_date = getDBInsertDateValue($avail_date);
    if ($owner != $userid) {
        $usr_query = "select activityid,vtiger_activity.date_start,vtiger_activity.due_date, vtiger_activity.time_start,vtiger_activity.duration_hours,vtiger_activity.duration_minutes,vtiger_crmentity.smownerid from vtiger_activity,vtiger_crmentity where vtiger_crmentity.crmid=vtiger_activity.activityid and ('" . $avail_date . "' like date_start) and vtiger_crmentity.smownerid=? and vtiger_activity.activityid !=?  and vtiger_crmentity.deleted=0";
    } else {
        $usr_query = "select activityid,vtiger_activity.date_start,vtiger_activity.due_date, vtiger_activity.time_start,vtiger_activity.duration_hours,vtiger_activity.duration_minutes,vtiger_crmentity.smownerid from vtiger_activity,vtiger_crmentity where vtiger_crmentity.crmid=vtiger_activity.activityid and ('" . $avail_date . "' like date_start) and vtiger_crmentity.smownerid=? and vtiger_activity.activityid !=? and vtiger_crmentity.deleted=0";
    }
    $result_cal = $adb->pquery($usr_query, array($userid, $activity_id));
    $noofrows_cal = $adb->num_rows($result_cal);
    $avail_flag = "false";
    if ($noofrows_cal != 0) {
        while ($row_cal = $adb->fetch_array($result_cal)) {
            $usr_date_start = $row_cal['date_start'];
            $usr_due_date = $row_cal['due_date'];
            $usr_time_start = $row_cal['time_start'];
            $usr_hour_dur = $row_cal['duration_hours'];
            $usr_mins_dur = $row_cal['duration_minutes'];
            $user_start_time = time_to_number($usr_time_start);
            $user_end_time = get_duration($usr_time_start, $usr_hour_dur, $usr_mins_dur);
            if ($user_start_time > $activity_start_time && $user_start_time < $activity_end_time || $user_end_time > $activity_start_time && $user_end_time < $activity_end_time || ($activity_start_time == $user_start_time || $activity_end_time == $user_end_time)) {
                $availability = 'busy';
                $avail_flag = "true";
                $log->info("user start time-- " . $user_start_time . "user end time" . $user_end_time);
                $log->info("Availability " . $availability);
            }
        }
    }
    if ($avail_flag != "true") {
        $recur_query = "SELECT vtiger_activity.activityid, vtiger_activity.time_start, vtiger_activity.duration_hours, vtiger_activity.duration_minutes , vtiger_crmentity.smownerid, vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid where ('" . $avail_date . "' like vtiger_recurringevents.recurringdate) and vtiger_crmentity.smownerid=? and vtiger_activity.activityid !=? and vtiger_crmentity.deleted=0";
        $result_cal = $adb->pquery($recur_query, array($userid, $activity_id));
        $noofrows_cal = $adb->num_rows($result_cal);
        $avail_flag = "false";
        if ($noofrows_cal != 0) {
            while ($row_cal = $adb->fetch_array($result_cal)) {
                $usr_date_start = $row_cal['date_start'];
                $usr_time_start = $row_cal['time_start'];
                $usr_hour_dur = $row_cal['duration_hours'];
                $usr_mins_dur = $row_cal['duration_minutes'];
                $user_start_time = time_to_number($usr_time_start);
                $user_end_time = get_duration($usr_time_start, $usr_hour_dur, $usr_mins_dur);
                if ($user_start_time > $activity_start_time && $user_start_time < $activity_end_time || $user_end_time > $activity_start_time && $user_end_time < $activity_end_time || ($activity_start_time == $user_start_time || $activity_end_time == $user_end_time)) {
                    $availability = 'busy';
                    $avail_flag = "true";
                    $log->info("Recurring Events:: user start time-- " . $user_start_time . "user end time" . $user_end_time);
                    $log->info("Recurring Events:: Availability " . $availability);
                }
            }
        }
    }
    if ($avail_flag == "true") {
        $availability = ' <IMG SRC="' . vtiger_imageurl('busy.gif', $theme) . '">';
    } else {
        $availability = ' <IMG SRC="' . vtiger_imageurl('free.gif', $theme) . '">';
    }
    $log->debug("Exiting status_availability method ...");
    return $availability;
}
コード例 #13
0
ファイル: utils.php プロジェクト: latechdirect/vtiger
/** Function to set date values compatible to database (YY_MM_DD)
 * @param $value -- value :: Type string
 * @returns $insert_date -- insert_date :: Type string
 */
function getValidDBInsertDateValue($value)
{
    global $log;
    $log->debug("Entering getDBInsertDateValue(" . $value . ") method ...");
    $delim = array('/', '.');
    foreach ($delim as $delimiter) {
        $x = strpos($value, $delimiter);
        if ($x === false) {
            continue;
        } else {
            $value = str_replace($delimiter, '-', $value);
            break;
        }
    }
    global $current_user;
    list($y, $m, $d) = explode('-', $value);
    if (strlen($y) < 4) {
        $insert_date = getDBInsertDateValue($value);
    } else {
        $insert_date = $value;
    }
    $log->debug("Exiting getDBInsertDateValue method ...");
    return $insert_date;
}
コード例 #14
0
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ********************************************************************************/
require_once 'include/database/PearDatabase.php';
require_once 'modules/Leads/Leads.php';
require_once 'include/ComboUtil.php';
//Getting the Parameters from the ConvertLead Form
$id = vtlib_purify($_REQUEST["record"]);
$module = vtlib_purify($_REQUEST["module"]);
$createpotential = $_REQUEST["createpotential"];
$potential_name = $_REQUEST["potential_name"];
$close_date = getDBInsertDateValue($_REQUEST["closedate"]);
$current_user_id = $_REQUEST["current_user_id"];
$assigned_to = $_REQUEST["assigntype"];
if ($assigned_to == "U") {
    $assigned_user_id = $_REQUEST["assigned_user_id"];
} else {
    $assigned_user_id = $_REQUEST["assigned_group_id"];
}
$accountname = $_REQUEST['account_name'];
$potential_amount = $_REQUEST['potential_amount'];
$potential_sales_stage = $_REQUEST['potential_sales_stage'];
global $log, $current_user;
require 'user_privileges/user_privileges_' . $current_user->id . '.php';
if ($assigned_to == "U") {
    $log->debug("id = {$id} \n assigned_user_id = {$assigned_user_id} \n createpotential = {$createpotential} \n close date = {$close_date} \n current user id = {$current_user_id} \n accountname = {$accountname} \n module = {$module}");
} else {
コード例 #15
0
ファイル: SearchUtils.php プロジェクト: latechdirect/vtiger
function getSearch_criteria($criteria, $searchstring, $searchfield)
{
    global $log;
    $log->debug("Entering getSearch_criteria(" . $criteria . "," . $searchstring . "," . $searchfield . ") method ...");
    $searchstring = ltrim(rtrim($searchstring));
    if ($searchfield != "vtiger_troubletickets.update_log" && ($searchfield == "vtiger_crmentity.modifiedtime" || $searchfield == "vtiger_crmentity.createdtime" || stristr($searchfield, 'date'))) {
        list($sdate, $stime) = split(" ", $searchstring);
        if ($stime != '') {
            $searchstring = getDBInsertDateValue($sdate) . " " . $stime;
        } else {
            $searchstring = getDBInsertDateValue($sdate);
        }
    }
    if ($searchfield == "vtiger_account.parentid") {
        $searchfield = "vtiger_account2.accountname";
    }
    if ($searchfield == "vtiger_pricebook.currency_id" || $searchfield == "vtiger_quotes.currency_id" || $searchfield == "vtiger_invoice.currency_id" || $searchfield == "vtiger_purchaseorder.currency_id" || $searchfield == "vtiger_salesorder.currency_id") {
        $searchfield = "vtiger_currency_info.currency_name";
    }
    $where_string = '';
    switch ($criteria) {
        case 'cts':
            $where_string = $searchfield . " like '" . formatForSqlLike($searchstring) . "' ";
            if ($searchstring == NULL) {
                $where_string = "(" . $searchfield . " like '' or " . $searchfield . " is NULL)";
            }
            break;
        case 'dcts':
            if ($searchfield == "vtiger_users.user_name" || $searchfield == "vtiger_groups.groupname") {
                $where_string = "(" . $searchfield . " not like '" . formatForSqlLike($searchstring) . "')";
            } else {
                $where_string = "(" . $searchfield . " not like '" . formatForSqlLike($searchstring) . "' or " . $searchfield . " is null)";
            }
            if ($searchstring == NULL) {
                $where_string = "(" . $searchfield . " not like '' or " . $searchfield . " is not NULL)";
            }
            break;
        case 'is':
            $where_string = $searchfield . " = '" . $searchstring . "' ";
            if ($searchstring == NULL) {
                $where_string = "(" . $searchfield . " is NULL or " . $searchfield . " = '')";
            }
            break;
        case 'isn':
            if ($searchfield == "vtiger_users.user_name" || $searchfield == "vtiger_groups.groupname") {
                $where_string = "(" . $searchfield . " <> '" . $searchstring . "')";
            } else {
                $where_string = "(" . $searchfield . " <> '" . $searchstring . "' or " . $searchfield . " is null)";
            }
            if ($searchstring == NULL) {
                $where_string = "(" . $searchfield . " not like '' and " . $searchfield . " is not NULL)";
            }
            break;
        case 'bwt':
            $where_string = $searchfield . " like '" . formatForSqlLike($searchstring, 2) . "' ";
            break;
        case 'ewt':
            $where_string = $searchfield . " like '" . formatForSqlLike($searchstring, 1) . "' ";
            break;
        case 'grt':
            $where_string = $searchfield . " > '" . $searchstring . "' ";
            break;
        case 'lst':
            $where_string = $searchfield . " < '" . $searchstring . "' ";
            break;
        case 'grteq':
            $where_string = $searchfield . " >= '" . $searchstring . "' ";
            break;
        case 'lsteq':
            $where_string = $searchfield . " <= '" . $searchstring . "' ";
            break;
    }
    $log->debug("Exiting getSearch_criteria method ...");
    return $where_string;
}