/** * Function to get the Audit Trail Information values of the actions performed by a particular User. * @param integer $userid - User's ID * @param $navigation_array - Array values to navigate through the number of entries. * @param $sortorder - DESC * @param $orderby - actiondate * Returns the audit trail entries in an array format. **/ function getAuditTrailEntries($userid, $navigation_array, $sorder = '', $orderby = '') { global $log; $log->debug("Entering getAuditTrailEntries(" . $userid . ") method ..."); global $adb, $current_user; if ($sorder != '' && $order_by != '') { $list_query = "Select * from vtiger_audit_trial where userid =? order by " . $order_by . " " . $sorder; } else { $list_query = "Select * from vtiger_audit_trial where userid =? order by " . $this->default_order_by . " " . $this->default_sort_order; } $result = $adb->pquery($list_query, array($userid)); $entries_list = array(); if ($navigation_array['end_val'] != 0) { for ($i = $navigation_array['start']; $i <= $navigation_array['end_val']; $i++) { $entries = array(); $userid = $adb->query_result($result, $i - 1, 'userid'); $entries[] = getTranslatedString($adb->query_result($result, $i - 1, 'module')); $entries[] = $adb->query_result($result, $i - 1, 'action'); $entries[] = $adb->query_result($result, $i - 1, 'recordid'); $entries[] = getDisplayDate($adb->query_result($result, $i - 1, 'actiondate')); $entries_list[] = $entries; } $log->debug("Exiting getAuditTrailEntries() method ..."); return $entries_list; } }
function edit() { $mainframe = JFactory::getApplication(); $jshopConfig = JSFactory::getConfig(); $db = JFactory::getDBO(); $me = JFactory::getUser(); $user_id = JRequest::getInt("user_id"); $user = JTable::getInstance('userShop', 'jshop'); $user->load($user_id); $user_site = new JUser($user_id); $_countries = $this->getModel("countries"); $countries = $_countries->getAllCountries(0); $lists['country'] = JHTML::_('select.genericlist', $countries, 'country', 'class = "inputbox" size = "1"', 'country_id', 'name', $user->country); $lists['d_country'] = JHTML::_('select.genericlist', $countries, 'd_country', 'class = "inputbox endes" size = "1"', 'country_id', 'name', $user->d_country); $user->birthday = getDisplayDate($user->birthday, $jshopConfig->field_birthday_format); $user->d_birthday = getDisplayDate($user->d_birthday, $jshopConfig->field_birthday_format); $option_title = array(); foreach ($jshopConfig->user_field_title as $key => $value) { $option_title[] = JHTML::_('select.option', $key, $value, 'title_id', 'title_name'); } $lists['select_titles'] = JHTML::_('select.genericlist', $option_title, 'title', 'class = "inputbox"', 'title_id', 'title_name', $user->title); $lists['select_d_titles'] = JHTML::_('select.genericlist', $option_title, 'd_title', 'class = "inputbox endes"', 'title_id', 'title_name', $user->d_title); $client_types = array(); foreach ($jshopConfig->user_field_client_type as $key => $value) { $client_types[] = JHTML::_('select.option', $key, $value, 'id', 'name'); } $lists['select_client_types'] = JHTML::_('select.genericlist', $client_types, 'client_type', 'class = "inputbox" ', 'id', 'name', $user->client_type); $_usergroups = $this->getModel("userGroups"); $usergroups = $_usergroups->getAllUsergroups(); $lists['usergroups'] = JHTML::_('select.genericlist', $usergroups, 'usergroup_id', 'class = "inputbox" size = "1"', 'usergroup_id', 'usergroup_name', $user->usergroup_id); $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user_site->get('block')); filterHTMLSafe($user, ENT_QUOTES); $tmp_fields = $jshopConfig->getListFieldsRegister(); $config_fields = $tmp_fields['editaccount']; $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('editaccount'); JHTML::_('behavior.calendar'); $view = $this->getView("users", 'html'); $view->setLayout("edit"); $view->assign('config', $jshopConfig); $view->assign('user', $user); $view->assign('me', $me); $view->assign('user_site', $user_site); $view->assign('lists', $lists); $view->assign('etemplatevar', ''); $view->assign('config_fields', $config_fields); $view->assign('count_filed_delivery', $count_filed_delivery); JPluginHelper::importPlugin('jshoppingadmin'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeEditUsers', array(&$view)); $view->displayEdit(); }
function getRequestedToData() { $mail_data = array(); $mail_data['user_id'] = $_REQUEST["task_assigned_user_id"]; $mail_data['subject'] = $_REQUEST['task_subject']; $mail_data['status'] = $_REQUEST['activity_mode'] == 'Task' ? $_REQUEST['taskstatus'] : $_REQUEST['eventstatus']; $mail_data['activity_mode'] = $_REQUEST['activity_mode']; $mail_data['taskpriority'] = $_REQUEST['taskpriority']; $mail_data['relatedto'] = $_REQUEST['task_parent_name']; $mail_data['contact_name'] = $_REQUEST['task_contact_name']; $mail_data['description'] = $_REQUEST['task_description']; $mail_data['assingn_type'] = $_REQUEST['task_assigntype']; $mail_data['group_name'] = getGroupName($_REQUEST['task_assigned_group_id']); $mail_data['mode'] = $_REQUEST['task_mode']; $value = getaddEventPopupTime($_REQUEST['task_time_start'], $_REQUEST['task_time_end'], '24'); $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt']; $mail_data['st_date_time'] = getDisplayDate($_REQUEST['task_date_start']) . " " . $start_hour; $mail_data['end_date_time'] = getDisplayDate($_REQUEST['task_due_date']); return $mail_data; }
function step2() { $checkout = JModelLegacy::getInstance('checkout', 'jshop'); $checkout->checkStep(2); JPluginHelper::importPlugin('jshoppingcheckout'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onLoadCheckoutStep2', array()); $session = JFactory::getSession(); $user = JFactory::getUser(); $jshopConfig = JSFactory::getConfig(); $country = JTable::getInstance('country', 'jshop'); $checkLogin = JRequest::getInt('check_login'); if ($checkLogin) { $session->set("show_pay_without_reg", 1); checkUserLogin(); } appendPathWay(_JSHOP_CHECKOUT_ADDRESS); $seo = JTable::getInstance("seo", "jshop"); $seodata = $seo->loadData("checkout-address"); if ($seodata->title == "") { $seodata->title = _JSHOP_CHECKOUT_ADDRESS; } setMetaData($seodata->title, $seodata->keyword, $seodata->description); $cart = JModelLegacy::getInstance('cart', 'jshop'); $cart->load(); $cart->getSum(); if ($user->id) { $adv_user = JSFactory::getUserShop(); } else { $adv_user = JSFactory::getUserShopGuest(); } $adv_user->birthday = getDisplayDate($adv_user->birthday, $jshopConfig->field_birthday_format); $adv_user->d_birthday = getDisplayDate($adv_user->d_birthday, $jshopConfig->field_birthday_format); $tmp_fields = $jshopConfig->getListFieldsRegister(); $config_fields = $tmp_fields['address']; $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('address'); $checkout_navigator = $this->_showCheckoutNavigation(2); if ($jshopConfig->show_cart_all_step_checkout) { $small_cart = $this->_showSmallCart(2); } else { $small_cart = ''; } $view_name = "checkout"; $view_config = array("template_path" => JPATH_COMPONENT . "/templates/" . $jshopConfig->template . "/" . $view_name); $view = $this->getView($view_name, getDocumentType(), '', $view_config); $view->setLayout("adress"); $view->assign('select', $jshopConfig->user_field_title); if (!$adv_user->country) { $adv_user->country = $jshopConfig->default_country; } if (!$adv_user->d_country) { $adv_user->d_country = $jshopConfig->default_country; } $option_country[] = JHTML::_('select.option', '0', _JSHOP_REG_SELECT, 'country_id', 'name'); $option_countryes = array_merge($option_country, $country->getAllCountries()); $select_countries = JHTML::_('select.genericlist', $option_countryes, 'country', 'class = "inputbox" size = "1"', 'country_id', 'name', $adv_user->country); $select_d_countries = JHTML::_('select.genericlist', $option_countryes, 'd_country', 'class = "inputbox" size = "1"', 'country_id', 'name', $adv_user->d_country); foreach ($jshopConfig->user_field_title as $key => $value) { $option_title[] = JHTML::_('select.option', $key, $value, 'title_id', 'title_name'); } $select_titles = JHTML::_('select.genericlist', $option_title, 'title', 'class = "inputbox"', 'title_id', 'title_name', $adv_user->title); $select_d_titles = JHTML::_('select.genericlist', $option_title, 'd_title', 'class = "inputbox"', 'title_id', 'title_name', $adv_user->d_title); $client_types = array(); foreach ($jshopConfig->user_field_client_type as $key => $value) { $client_types[] = JHTML::_('select.option', $key, $value, 'id', 'name'); } $select_client_types = JHTML::_('select.genericlist', $client_types, 'client_type', 'class = "inputbox" onchange="showHideFieldFirm(this.value)"', 'id', 'name', $adv_user->client_type); filterHTMLSafe($adv_user, ENT_QUOTES); if ($config_fields['birthday']['display'] || $config_fields['d_birthday']['display']) { JHTML::_('behavior.calendar'); } $view->assign('config', $jshopConfig); $view->assign('select_countries', $select_countries); $view->assign('select_d_countries', $select_d_countries); $view->assign('select_titles', $select_titles); $view->assign('select_d_titles', $select_d_titles); $view->assign('select_client_types', $select_client_types); $view->assign('live_path', JURI::base()); $view->assign('config_fields', $config_fields); $view->assign('count_filed_delivery', $count_filed_delivery); $view->assign('user', $adv_user); $view->assign('delivery_adress', $adv_user->delivery_adress); $view->assign('checkout_navigator', $checkout_navigator); $view->assign('small_cart', $small_cart); $view->assign('action', SEFLink('index.php?option=com_jshopping&controller=checkout&task=step2save', 0, 0, $jshopConfig->use_ssl)); $dispatcher->trigger('onBeforeDisplayCheckoutStep2View', array(&$view)); $view->display(); }
/** Function used to get the Quote Stage history of the Quotes * @param $id - quote id * @return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are arrays which contains header values and all column values of all entries */ function get_quotestagehistory($id) { global $log; $log->debug("Entering get_quotestagehistory(" . $id . ") method ..."); global $adb; global $mod_strings; global $app_strings; $query = 'select vtiger_quotestagehistory.*, vtiger_quotes.quote_no from vtiger_quotestagehistory inner join vtiger_quotes on vtiger_quotes.quoteid = vtiger_quotestagehistory.quoteid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_quotes.quoteid where vtiger_crmentity.deleted = 0 and vtiger_quotes.quoteid = ?'; $result = $adb->pquery($query, array($id)); $noofrows = $adb->num_rows($result); $header[] = $app_strings['Quote No']; $header[] = $app_strings['LBL_ACCOUNT_NAME']; $header[] = $app_strings['LBL_AMOUNT']; $header[] = $app_strings['Quote Stage']; $header[] = $app_strings['LBL_LAST_MODIFIED']; //Getting the field permission for the current user. 1 - Not Accessible, 0 - Accessible //Account Name , Total are mandatory fields. So no need to do security check to these fields. global $current_user; //If field is accessible then getFieldVisibilityPermission function will return 0 else return 1 $quotestage_access = getFieldVisibilityPermission('Quotes', $current_user->id, 'quotestage') != '0' ? 1 : 0; $picklistarray = getAccessPickListValues('Quotes'); $quotestage_array = $quotestage_access != 1 ? $picklistarray['quotestage'] : array(); //- ==> picklist field is not permitted in profile //Not Accessible - picklist is permitted in profile but picklist value is not permitted $error_msg = $quotestage_access != 1 ? 'Not Accessible' : '-'; while ($row = $adb->fetch_array($result)) { $entries = array(); // Module Sequence Numbering //$entries[] = $row['quoteid']; $entries[] = $row['quote_no']; // END $entries[] = $row['accountname']; $entries[] = $row['total']; $entries[] = in_array($row['quotestage'], $quotestage_array) ? $row['quotestage'] : $error_msg; $entries[] = getDisplayDate($row['lastmodified']); $entries_list[] = $entries; } $return_data = array('header' => $header, 'entries' => $entries_list); $log->debug("Exiting get_quotestagehistory method ..."); return $return_data; }
function edit() { $mainframe = JFactory::getApplication(); $order_id = JRequest::getVar("order_id"); $client_id = JRequest::getInt('client_id', 0); $lang = JSFactory::getLang(); $db = JFactory::getDBO(); $jshopConfig = JSFactory::getConfig(); $orders = $this->getModel("orders"); $order = JTable::getInstance('order', 'jshop'); $order->load($order_id); $name = $lang->get("name"); $id_vendor_cuser = getIdVendorForCUser(); if ($jshopConfig->admin_show_vendors && $id_vendor_cuser) { if ($order->vendor_id != $id_vendor_cuser) { $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); return 0; } } $order_items = $order->getAllItems(); $_languages = $this->getModel("languages"); $languages = $_languages->getAllLanguages(1); $select_language = JHTML::_('select.genericlist', $languages, 'lang', 'class = "inputbox" style="float:none"', 'language', 'name', $order->lang); $country = JTable::getInstance('country', 'jshop'); $countries = $country->getAllCountries(); $select_countries = JHTML::_('select.genericlist', $countries, 'country', 'class = "inputbox"', 'country_id', 'name', $order->country); $select_d_countries = JHTML::_('select.genericlist', $countries, 'd_country', 'class = "inputbox"', 'country_id', 'name', $order->d_country); $option_title = array(); foreach ($jshopConfig->user_field_title as $key => $value) { if ($key > 0) { $option_title[] = JHTML::_('select.option', $key, $value, 'title_id', 'title_name'); } } $select_titles = JHTML::_('select.genericlist', $option_title, 'title', 'class = "inputbox"', 'title_id', 'title_name', $order->title); $select_d_titles = JHTML::_('select.genericlist', $option_title, 'd_title', 'class = "inputbox endes"', 'title_id', 'title_name', $order->d_title); $order->birthday = getDisplayDate($order->birthday, $jshopConfig->field_birthday_format); $order->d_birthday = getDisplayDate($order->d_birthday, $jshopConfig->field_birthday_format); $client_types = array(); foreach ($jshopConfig->user_field_client_type as $key => $value) { $client_types[] = JHTML::_('select.option', $key, $value, 'id', 'name'); } $select_client_types = JHTML::_('select.genericlist', $client_types, 'client_type', 'class = "inputbox" onchange="showHideFieldFirm(this.value)"', 'id', 'name', $order->client_type); $jshopConfig->user_field_client_type[0] = ""; if (isset($jshopConfig->user_field_client_type[$order->client_type])) { $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type]; } else { $order->client_type_name = ''; } $tmp_fields = $jshopConfig->getListFieldsRegister(); $config_fields = $tmp_fields["address"]; $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('address'); $pm_method = JTable::getInstance('paymentMethod', 'jshop'); $pm_method->load($order->payment_method_id); $order->payment_name = $pm_method->{$name}; $order->order_tax_list = $order->getTaxExt(); $_currency = $this->getModel("currencies"); $currency_list = $_currency->getAllCurrencies(); $order_currency = 0; foreach ($currency_list as $k => $v) { if ($v->currency_code_iso == $order->currency_code_iso) { $order_currency = $v->currency_id; } } $select_currency = JHTML::_('select.genericlist', $currency_list, 'currency_id', 'class = "inputbox"', 'currency_id', 'currency_code', $order_currency); $display_price_list = array(); $display_price_list[] = JHTML::_('select.option', 0, _JSHOP_PRODUCT_BRUTTO_PRICE, 'id', 'name'); $display_price_list[] = JHTML::_('select.option', 1, _JSHOP_PRODUCT_NETTO_PRICE, 'id', 'name'); $display_price_select = JHTML::_('select.genericlist', $display_price_list, 'display_price', 'onchange="updateOrderTotalValue();"', 'id', 'name', $order->display_price); $shippings = $this->getModel("shippings"); $shippings_list = $shippings->getAllShippings(0); $shippings_select = JHTML::_('select.genericlist', $shippings_list, 'shipping_method_id', '', 'shipping_id', 'name', $order->shipping_method_id); $payments = $this->getModel("payments"); $payments_list = $payments->getAllPaymentMethods(0); $payments_select = JHTML::_('select.genericlist', $payments_list, 'payment_method_id', '', 'payment_id', 'name', $order->payment_method_id); $deliverytimes = JSFactory::getAllDeliveryTime(); $first = array(0 => "- - -"); $delivery_time_select = JHTML::_('select.genericlist', array_merge($first, $deliverytimes), 'delivery_times_id', '', 'id', 'name', $order->delivery_times_id); $users = $this->getModel('users'); $users_list = $users->getUsers(); $first = array(0 => '- - -'); $users_list_select = JHTML::_('select.genericlist', array_merge($first, $users_list), 'user_id', 'onchange="updateBillingShippingForUser(this.value);"', 'user_id', 'name', $order->user_id); filterHTMLSafe($order); foreach ($order_items as $k => $v) { JFilterOutput::objectHTMLSafe($order_items[$k]); } JHTML::_('behavior.calendar'); $view = $this->getView("orders", 'html'); $view->setLayout("edit"); $view->assign('config', $jshopConfig); $view->assign('order', $order); $view->assign('order_items', $order_items); $view->assign('config_fields', $config_fields); $view->assign('etemplatevar', ''); $view->assign('count_filed_delivery', $count_filed_delivery); $view->assign('order_id', $order_id); $view->assign('select_countries', $select_countries); $view->assign('select_d_countries', $select_d_countries); $view->assign('select_titles', $select_titles); $view->assign('select_d_titles', $select_d_titles); $view->assign('select_client_types', $select_client_types); $view->assign('select_currency', $select_currency); $view->assign('display_price_select', $display_price_select); $view->assign('shippings_select', $shippings_select); $view->assign('payments_select', $payments_select); $view->assign('select_language', $select_language); $view->assign('delivery_time_select', $delivery_time_select); $view->assign('users_list_select', $users_list_select); $view->assign('client_id', $client_id); JPluginHelper::importPlugin('jshoppingadmin'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeEditOrders', array(&$view)); $view->displayEdit(); }
function getValue($field_result, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype, $returnset = '', $viewid = '') { global $log, $listview_max_textlength, $app_strings, $current_language, $currentModule; $log->debug("Entering getValue(" . $field_result . "," . $list_result . "," . $fieldname . "," . get_class($focus) . "," . $module . "," . $entity_id . "," . $list_result_count . "," . $mode . "," . $popuptype . "," . $returnset . "," . $viewid . ") method ..."); global $adb, $current_user, $default_charset; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $tabname = getParentTab(); $tabid = getTabid($module); $current_module_strings = return_module_language($current_language, $module); $uicolarr = $field_result[$fieldname]; foreach ($uicolarr as $key => $value) { $uitype = $key; $colname = $value; } //added for getting event status in Custom view - Jaguar if ($module == 'Calendar' && ($colname == "status" || $colname == "eventstatus")) { $colname = "activitystatus"; } //Ends $field_val = $adb->query_result($list_result, $list_result_count, $colname); if (stristr(html_entity_decode($field_val), "<a href") === false && $uitype != 8) { $temp_val = textlength_check($field_val); } elseif ($uitype != 8) { $temp_val = html_entity_decode($field_val, ENT_QUOTES); } else { $temp_val = $field_val; } // vtlib customization: New uitype to handle relation between modules if ($uitype == '10') { $parent_id = $field_val; if (!empty($parent_id)) { $parent_module = getSalesEntityType($parent_id); $valueTitle = $parent_module; if ($app_strings[$valueTitle]) { $valueTitle = $app_strings[$valueTitle]; } $displayValueArray = getEntityName($parent_module, $parent_id); if (!empty($displayValueArray)) { foreach ($displayValueArray as $key => $value) { $displayValue = $value; } } $value = "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>"; } else { $value = ''; } } else { if ($uitype == 53) { $value = textlength_check($adb->query_result($list_result, $list_result_count, 'user_name')); // When Assigned To field is used in Popup window if ($value == '') { $user_id = $adb->query_result($list_result, $list_result_count, 'smownerid'); if ($user_id != null && $user_id != '') { $value = getOwnerName($user_id); } } } elseif ($uitype == 52) { $value = getUserName($adb->query_result($list_result, $list_result_count, $colname)); } elseif ($uitype == 51) { $parentid = $adb->query_result($list_result, $list_result_count, "parentid"); if ($module == 'Accounts') { $entity_name = textlength_check(getAccountName($parentid)); } elseif ($module == 'Products') { $entity_name = textlength_check(getProductName($parentid)); } $value = '<a href="index.php?module=' . $module . '&action=DetailView&record=' . $parentid . '&parenttab=' . $tabname . '" style="' . $P_FONT_COLOR . '">' . $entity_name . '</a>'; } elseif ($uitype == 77) { $value = getUserName($adb->query_result($list_result, $list_result_count, 'inventorymanager')); } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) { if ($temp_val != '' && $temp_val != '0000-00-00') { $value = getDisplayDate($temp_val); } elseif ($temp_val == '0000-00-00') { $value = ''; } else { $value = $temp_val; } } elseif ($uitype == 15 || $uitype == 55 && $fieldname == "salutationtype") { $temp_val = decode_html($adb->query_result($list_result, $list_result_count, $colname)); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $temp_val != '') { $temp_acttype = $adb->query_result($list_result, $list_result_count, 'activitytype'); if ($temp_acttype != 'Task' && $fieldname == "taskstatus") { $temptable = "eventstatus"; } else { $temptable = $fieldname; } $roleid = $current_user->roleid; $roleids = array(); $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; } array_push($roleids, $roleid); //here we are checking wheather the table contains the sortorder column .If sortorder is present in the main picklist table, then the role2picklist will be applicable for this table... $sql = "select * from vtiger_{$temptable} where {$temptable}=?"; $res = $adb->pquery($sql, array(decode_html($temp_val))); $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid'); if ($picklistvalueid != null) { $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")"; $res_val = $adb->pquery($pick_query, array($roleids)); $num_val = $adb->num_rows($res_val); } if ($num_val > 0 || $temp_acttype == 'Task' && $fieldname == 'activitytype') { $temp_val = $temp_val; } else { $temp_val = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; } } $value = $current_module_strings[$temp_val] != '' ? $current_module_strings[$temp_val] : ($app_strings[$temp_val] != '' ? $app_strings[$temp_val] : $temp_val); if ($value != "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>") { $value = textlength_check($value); } } elseif ($uitype == 16) { $value = getTranslatedString($temp_val, $currentModule); } elseif ($uitype == 71 || $uitype == 72) { if ($temp_val != '') { if ($fieldname == 'unit_price') { $currency_id = getProductBaseCurrency($entity_id, $module); $cursym_convrate = getCurrencySymbolandCRate($currency_id); $value = "<font style='color:grey;'>" . $cursym_convrate['symbol'] . "</font> " . $temp_val; } else { $rate = $user_info['conv_rate']; //changes made to remove vtiger_currency symbol infront of each vtiger_potential amount if ($temp_val != 0) { $value = convertFromDollar($temp_val, $rate); } else { $value = $temp_val; } } } else { $value = ''; } } elseif ($uitype == 17) { $value = '<a href="http://' . $field_val . '" target="_blank">' . $temp_val . '</a>'; } elseif ($uitype == 13 || $uitype == 104 && ($_REQUEST['action'] != 'Popup' && $_REQUEST['file'] != 'Popup')) { if ($_SESSION['internal_mailer'] == 1) { //check added for email link in user detailview if ($module == 'Calendar') { if (getActivityType($entity_id) == 'Task') { $tabid = 9; } else { $tabid = 16; } } else { $tabid = getTabid($module); } $fieldid = getFieldid($tabid, $fieldname); if (empty($popuptype)) { $value = '<a href="javascript:InternalMailer(' . $entity_id . ',' . $fieldid . ',\'' . $fieldname . '\',\'' . $module . '\',\'record_id\');">' . $temp_val . '</a>'; } else { $value = $temp_val; } } else { $value = '<a href="mailto:' . $field_val . '">' . $temp_val . '</a>'; } } elseif ($uitype == 56) { if ($temp_val == 1) { $value = $app_strings['yes']; } elseif ($temp_val == 0) { $value = $app_strings['no']; } else { $value = ''; } } elseif ($uitype == 57) { if ($temp_val != '') { $sql = "SELECT * FROM vtiger_contactdetails WHERE contactid=?"; $result = $adb->pquery($sql, array($temp_val)); $value = ''; if ($adb->num_rows($result)) { $name = getFullNameFromQResult($result, 0, "Contacts"); $value = '<a href=index.php?module=Contacts&action=DetailView&record=' . $temp_val . '>' . $name . '</a>'; } } else { $value = ''; } } elseif ($uitype == 58) { if ($temp_val != '') { $sql = "SELECT * FROM vtiger_campaign WHERE campaignid=?"; $result = $adb->pquery($sql, array($temp_val)); $campaignname = $adb->query_result($result, 0, "campaignname"); $value = '<a href=index.php?module=Campaigns&action=DetailView&record=' . $temp_val . '>' . $campaignname . '</a>'; } else { $value = ''; } } elseif ($uitype == 59) { if ($temp_val != '') { $value = getProductName($temp_val); } else { $value = ''; } } elseif ($uitype == 61) { $attachmentid = $adb->query_result($adb->pquery("SELECT * FROM vtiger_seattachmentsrel WHERE crmid = ?", array($entity_id)), 0, 'attachmentsid'); $value = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $module . '&fileid=' . $attachmentid . '&filename=' . $temp_val . '">' . $temp_val . '</a>'; } elseif ($uitype == 62) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parenttype == "Products") { $tablename = "vtiger_products"; $fieldname = "productname"; $idname = "productid"; } if ($parenttype == "HelpDesk") { $tablename = "vtiger_troubletickets"; $fieldname = "title"; $idname = "ticketid"; } if ($parenttype == "Invoice") { $tablename = "vtiger_invoice"; $fieldname = "subject"; $idname = "invoiceid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 66) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parenttype == "HelpDesk") { $tablename = "vtiger_troubletickets"; $fieldname = "title"; $idname = "ticketid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 67) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == "Leads") { $tablename = "vtiger_leaddetails"; $fieldname = "lastname"; $idname = "leadid"; } if ($parenttype == "Contacts") { $tablename = "vtiger_contactdetails"; $fieldname = "contactname"; $idname = "contactid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 68) { $parentid = $adb->query_result($list_result, $list_result_count, "parent_id"); $parenttype = $adb->query_result($list_result, $list_result_count, "parent_type"); if ($parenttype == '' && $parentid != '') { $parenttype = getSalesEntityType($parentid); } if ($parenttype == "Contacts") { $tablename = "vtiger_contactdetails"; $fieldname = "contactname"; $idname = "contactid"; } if ($parenttype == "Accounts") { $tablename = "vtiger_account"; $fieldname = "accountname"; $idname = "accountid"; } if ($parentid != '') { $sql = "SELECT * FROM {$tablename} WHERE {$idname} = ?"; $fieldvalue = $adb->query_result($adb->pquery($sql, array($parentid)), 0, $fieldname); $value = '<a href=index.php?module=' . $parenttype . '&action=DetailView&record=' . $parentid . '&parenttab=' . urlencode($tabname) . '>' . $fieldvalue . '</a>'; } else { $value = ''; } } elseif ($uitype == 78) { if ($temp_val != '') { $quote_name = getQuoteName($temp_val); $value = '<a href=index.php?module=Quotes&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($quote_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 79) { if ($temp_val != '') { $purchaseorder_name = getPoName($temp_val); $value = '<a href=index.php?module=PurchaseOrder&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($purchaseorder_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 80) { if ($temp_val != '') { $salesorder_name = getSoName($temp_val); $value = "<a href=index.php?module=SalesOrder&action=DetailView&record={$temp_val}&parenttab=" . urlencode($tabname) . ">" . textlength_check($salesorder_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 75 || $uitype == 81) { if ($temp_val != '') { $vendor_name = getVendorName($temp_val); $value = '<a href=index.php?module=Vendors&action=DetailView&record=' . $temp_val . '&parenttab=' . urlencode($tabname) . '>' . textlength_check($vendor_name) . '</a>'; } else { $value = ''; } } elseif ($uitype == 98) { $value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=Settings&roleid=' . $temp_val . '">' . textlength_check(getRoleName($temp_val)) . '</a>'; } elseif ($uitype == 33) { $value = $temp_val != "" ? str_ireplace(' |##| ', ', ', $temp_val) : ""; if (!$is_admin && $value != '') { $value = $field_val != "" ? str_ireplace(' |##| ', ', ', $field_val) : ""; if ($value != '') { $value_arr = explode(',', trim($value)); $roleid = $current_user->roleid; $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; array_push($roleids, $roleid); } else { $roleids = $roleid; } if (count($roleids) > 0) { $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where roleid in (" . generateQuestionMarks($roleids) . ") and picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc"; $params = array($roleids); } else { $pick_query = "select distinct {$fieldname} from vtiger_{$fieldname} inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_{$fieldname}.picklist_valueid where picklistid in (select picklistid from vtiger_{$fieldname}) order by {$fieldname} asc"; $params = array(); } $pickListResult = $adb->pquery($pick_query, $params); $picklistval = array(); for ($i = 0; $i < $adb->num_rows($pickListResult); $i++) { $picklistarr[] = $adb->query_result($pickListResult, $i, $fieldname); } $value_temp = array(); $string_temp = ''; $str_c = 0; foreach ($value_arr as $ind => $val) { $notaccess = '<font color="red">' . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; if (!$listview_max_textlength || !(strlen(preg_replace("/(<\\/?)(\\w+)([^>]*>)/i", "", $string_temp)) > $listview_max_textlength)) { $value_temp1 = in_array(trim($val), $picklistarr) ? $val : $notaccess; if ($str_c != 0) { $string_temp .= ' , '; } $string_temp .= $value_temp1; $str_c++; } else { $string_temp .= '...'; } } $value = $string_temp; } } } elseif ($uitype == 85) { $value = $temp_val != "" ? "<a href='skype:{$temp_val}?call'>{$temp_val}</a>" : ""; } elseif ($uitype == 116) { $value = $temp_val != "" ? getCurrencyName($temp_val) : ""; } elseif ($uitype == 117) { // NOTE: Without symbol the value could be used for filtering/lookup hence avoiding the translation $value = $temp_val != "" ? getCurrencyName($temp_val, false) : ""; } elseif ($uitype == 26) { $sql = "select foldername from vtiger_attachmentsfolder where folderid = ?"; $res = $adb->pquery($sql, array($temp_val)); $foldername = $adb->query_result($res, 0, 'foldername'); $value = $foldername; } elseif ($uitype == 11) { // Fix added for Trac Id: 6139 if (vtlib_isModuleActive('PBXManager')) { $value = "<a href='javascript:;' onclick='startCall("{$temp_val}", "{$entity_id}")'>" . $temp_val . "</a>"; } else { $value = $temp_val; } } elseif ($uitype == 25) { $contactid = $_REQUEST['record']; $emailid = $adb->query_result($list_result, $list_result_count, "activityid"); $result = $adb->pquery("SELECT access_count FROM vtiger_email_track WHERE crmid=? AND mailid=?", array($contactid, $emailid)); $value = $adb->query_result($result, 0, "access_count"); if (!$value) { $value = 0; } } elseif ($uitype == 8) { if (!empty($temp_val)) { $temp_val = html_entity_decode($temp_val, ENT_QUOTES, $default_charset); $json = new Zend_Json(); $value = vt_suppressHTMLTags(implode(',', $json->decode($temp_val))); } } else { if ($fieldname == $focus->list_link_field) { if ($mode == "search") { if ($popuptype == "specific" || $popuptype == "toDospecific") { // Added for get the first name of contact in Popup window if ($colname == "lastname" && $module == 'Contacts') { $temp_val = getFullNameFromQResult($list_result, $list_result_count, "Contacts"); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); //Added to avoid the error when select SO from Invoice through AjaxEdit if ($module == 'SalesOrder') { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '","' . $_REQUEST['form'] . '");\'>' . $temp_val . '</a>'; } elseif ($module == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $cntct_focus = new Contacts(); $cntct_focus->retrieve_entity_info($entity_id, "Contacts"); $slashes_temp_val = popup_from_html($temp_val); //ADDED TO CHECK THE FIELD PERMISSIONS FOR $xyz = array('mailingstreet', 'mailingcity', 'mailingzip', 'mailingpobox', 'mailingcountry', 'mailingstate', 'otherstreet', 'othercity', 'otherzip', 'otherpobox', 'othercountry', 'otherstate'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $cntct_focus->column_fields[$xyz[$i]] = $cntct_focus->column_fields[$xyz[$i]]; } else { $cntct_focus->column_fields[$xyz[$i]] = ''; } } // For ToDo creation the underlying form is not named as EditView $form = !empty($_REQUEST['form']) ? $_REQUEST['form'] : ''; if (!empty($form)) { $form = htmlspecialchars($form, ENT_QUOTES, $default_charset); } $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstreet']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcity']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercity']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherstate']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherzip']) . '", "' . popup_decode_html($cntct_focus->column_fields['mailingcountry']) . '", "' . popup_decode_html($cntct_focus->column_fields['othercountry']) . '","' . popup_decode_html($cntct_focus->column_fields['mailingpobox']) . '", "' . popup_decode_html($cntct_focus->column_fields['otherpobox']) . '","' . $form . '");\'>' . $temp_val . '</a>'; } else { if ($popuptype == 'toDospecific') { $value = '<a href="javascript:window.close();" onclick=\'set_return_toDospecific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } } } elseif ($popuptype == "detailview") { if ($colname == "lastname" && ($module == 'Contacts' || $module == 'Leads')) { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $focus->record_id = $_REQUEST['recordid']; if ($_REQUEST['return_module'] == "Calendar") { $value = '<a href="javascript:window.close();" id="calendarCont' . $entity_id . '" LANGUAGE=javascript onclick=\'add_data_to_relatedlist_incal("' . $entity_id . '","' . decode_html($slashes_temp_val) . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '");\'>' . $temp_val . '</a>'; } } elseif ($popuptype == "formname_specific") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'set_return_formname_specific("' . $_REQUEST['form'] . '", "' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id)); $unitprice = $prod_prices[$entity_id]; } } else { $unit_price = ''; } $sub_products = ''; $sub_prod = ''; $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id)); for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) { //$sub_prod=array(); $id = $adb->query_result($sub_prod_query, $i, "productid"); $str_sep = ''; if ($i > 0) { $str_sep = ":"; } $sub_products .= $str_sep . $id; $sub_prod .= $str_sep . " - " . $adb->query_result($sub_prod_query, $i, "productname"); } $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod); $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); //fix for T6943 $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $qty_stock . '","' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod_po") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module); $unitprice = $prod_prices[$entity_id]; } } else { $unit_price = ''; } $sub_products = ''; $sub_prod = ''; $sub_prod_query = $adb->pquery("SELECT vtiger_products.productid,vtiger_products.productname,vtiger_products.qtyinstock,vtiger_crmentity.description from vtiger_products INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid INNER JOIN vtiger_seproductsrel on vtiger_seproductsrel.crmid=vtiger_products.productid WHERE vtiger_seproductsrel.productid=? and vtiger_seproductsrel.setype='Products'", array($entity_id)); for ($i = 0; $i < $adb->num_rows($sub_prod_query); $i++) { //$sub_prod=array(); $id = $adb->query_result($sub_prod_query, $i, "productid"); $str_sep = ''; if ($i > 0) { $str_sep = ":"; } $sub_products .= $str_sep . $id; $sub_prod .= $str_sep . " - {$id}." . $adb->query_result($sub_prod_query, $i, "productname"); } $sub_det = $sub_products . "::" . str_replace(":", "<br>", $sub_prod); $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "qtyinstk" => "{$qty_stock}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}", "subprod_ids" => "{$sub_det}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory_po("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '","' . $sub_det . '"); \' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_service") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $tax_details = getAllTaxes(); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $tax_str .= $tax_details[$tax_count]['taxname'] . '=' . $tax_details[$tax_count]['percentage'] . ','; } $tax_str = trim($tax_str, ','); $rate = $user_info['conv_rate']; if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); if ($_REQUEST['currencyid'] != null) { $prod_prices = getPricesForProducts($_REQUEST['currencyid'], array($entity_id), $module); $unitprice = $prod_prices[$entity_id]; } } else { $unit_price = ''; } $slashes_temp_val = popup_from_html($field_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $description = popup_from_html($adb->query_result($list_result, $list_result_count, 'description')); $slashes_temp_desc = decode_html(htmlspecialchars($description, ENT_QUOTES, $default_charset)); $slashes_desc = str_replace(array("\r", "\n"), array('\\r', '\\n'), $slashes_temp_desc); $tmp_arr = array("entityid" => $entity_id, "prodname" => "" . stripslashes(decode_html(nl2br($slashes_temp_val))) . "", "unitprice" => "{$unitprice}", "taxstring" => "{$tax_str}", "rowid" => "{$row_id}", "desc" => "{$slashes_desc}"); require_once 'include/Zend/Json.php'; $prod_arr = Zend_Json::encode($tmp_arr); $value = '<a href="javascript:window.close();" id=\'popup_product_' . $entity_id . '\' onclick=\'set_return_inventory("' . $entity_id . '", "' . decode_html(nl2br($slashes_temp_val)) . '", "' . $unitprice . '", "' . $tax_str . '","' . $row_id . '","' . $slashes_desc . '");\' vt_prod_arr=\'' . $prod_arr . '\' >' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_pb") { $prod_id = $_REQUEST['productid']; $flname = $_REQUEST['fldname']; $listprice = getListPrice($prod_id, $entity_id); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_pb("' . $listprice . '", "' . $flname . '"); \'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_contact_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_potential_account_address") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); // For B2C support, Potential was enabled to be linked to Contacts also. // Hence we need case handling for it. $relatedid = $adb->query_result($list_result, $list_result_count, "related_to"); $relatedentity = getSalesEntityType($relatedid); if ($relatedentity == 'Accounts') { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($relatedid, "Accounts"); $account_name = getAccountName($relatedid); $slashes_account_name = popup_from_html($account_name); $slashes_account_name = htmlspecialchars($slashes_account_name, ENT_QUOTES, $default_charset); $xyz = array('bill_street', 'bill_city', 'bill_code', 'bill_pobox', 'bill_country', 'bill_state', 'ship_street', 'ship_city', 'ship_code', 'ship_pobox', 'ship_country', 'ship_state'); for ($i = 0; $i < 12; $i++) { if (getFieldVisibilityPermission('Accounts', $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['bill_street'])); $ship_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['ship_street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_account_name)) . '", "' . $bill_street . '", "' . $ship_street . '", "' . popup_decode_html($acct_focus->column_fields['bill_city']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_city']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_state']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_state']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_code']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_code']) . '", "' . popup_decode_html($acct_focus->column_fields['bill_country']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_country']) . '","' . popup_decode_html($acct_focus->column_fields['bill_pobox']) . '", "' . popup_decode_html($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } else { if ($relatedentity == 'Contacts') { require_once 'modules/Contacts/Contacts.php'; $contact_name = getContactName($relatedid); $slashes_contact_name = popup_from_html($contact_name); $slashes_contact_name = htmlspecialchars($slashes_contact_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $relatedid . '", "' . nl2br(decode_html($slashes_contact_name)) . '");\'>' . $temp_val . '</a>'; } else { $value = $temp_val; } } } elseif ($popuptype == "set_return_emails") { if ($module == 'Accounts') { $name = $adb->query_result($list_result, $list_result_count, 'accountname'); $accid = $adb->query_result($list_result, $list_result_count, 'accountid'); if (CheckFieldPermission('email1', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email1"); $email_check = 1; } else { $email_check = 0; } if ($emailaddress == '') { if (CheckFieldPermission('email2', $module) == 'true') { $emailaddress2 = $adb->query_result($list_result, $list_result_count, "email2"); $email_check = 2; } else { if ($email_check == 1) { $email_check = 4; } else { $email_check = 3; } } } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>'; } elseif ($module == 'Vendors') { $name = $adb->query_result($list_result, $list_result_count, 'vendorname'); $venid = $adb->query_result($list_result, $list_result_count, 'vendorid'); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email1 or email2 $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>'; } elseif ($module == 'Contacts' || $module == 'Leads') { $name = getFullNameFromQResult($list_result, $list_result_count, $module); if (CheckFieldPermission('email', $module) == "true") { $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); $email_check = 1; } else { $email_check = 0; } if ($emailaddress == '') { if (CheckFieldPermission('yahooid', $module) == 'true') { $emailaddress2 = $adb->query_result($list_result, $list_result_count, "yahooid"); $email_check = 2; } else { if ($email_check == 1) { $email_check = 4; } else { $email_check = 3; } } } $querystr = "SELECT fieldid,fieldlabel,columnname FROM vtiger_field WHERE tabid=? and uitype=13 and vtiger_field.presence in (0,2)"; $queryres = $adb->pquery($querystr, array(getTabid($module))); //Change this index 0 - to get the vtiger_fieldid based on email or yahooid $fieldid = $adb->query_result($queryres, 0, 'fieldid'); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',' . $fieldid . ',"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . $name . '</a>'; } else { $firstname = $adb->query_result($list_result, $list_result_count, "first_name"); $lastname = $adb->query_result($list_result, $list_result_count, "last_name"); $name = $lastname . ' ' . $firstname; $emailaddress = $adb->query_result($list_result, $list_result_count, "email1"); $slashes_name = popup_from_html($name); $slashes_name = htmlspecialchars($slashes_name, ENT_QUOTES, $default_charset); $email_check = 1; $value = '<a href="javascript:window.close();" onclick=\'return set_return_emails(' . $entity_id . ',-1,"' . decode_html($slashes_name) . '","' . $emailaddress . '","' . $emailaddress2 . '","' . $email_check . '"); \'>' . textlength_check($name) . '</a>'; } } elseif ($popuptype == "specific_vendor_address") { require_once 'modules/Vendors/Vendors.php'; $acct_focus = new Vendors(); $acct_focus->retrieve_entity_info($entity_id, "Vendors"); $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $xyz = array('street', 'city', 'postalcode', 'pobox', 'country', 'state'); for ($i = 0; $i < 6; $i++) { if (getFieldVisibilityPermission($module, $current_user->id, $xyz[$i]) == '0') { $acct_focus->column_fields[$xyz[$i]] = $acct_focus->column_fields[$xyz[$i]]; } else { $acct_focus->column_fields[$xyz[$i]] = ''; } } $bill_street = str_replace(array("\r", "\n"), array('\\r', '\\n'), popup_decode_html($acct_focus->column_fields['street'])); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '", "' . $bill_street . '", "' . popup_decode_html($acct_focus->column_fields['city']) . '", "' . popup_decode_html($acct_focus->column_fields['state']) . '", "' . popup_decode_html($acct_focus->column_fields['postalcode']) . '", "' . popup_decode_html($acct_focus->column_fields['country']) . '","' . popup_decode_html($acct_focus->column_fields['pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_campaign") { $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $value = '<a href="javascript:window.close();" onclick=\'set_return_specific_campaign("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } else { if ($colname == "lastname") { $temp_val = getFullNameFromQResult($list_result, $list_result_count, $module); } $slashes_temp_val = popup_from_html($temp_val); $slashes_temp_val = htmlspecialchars($slashes_temp_val, ENT_QUOTES, $default_charset); $log->debug("Exiting getValue method ..."); if ($_REQUEST['maintab'] == 'Calendar') { $value = '<a href="javascript:window.close();" onclick=\'set_return_todo("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'set_return("' . $entity_id . '", "' . nl2br(decode_html($slashes_temp_val)) . '");\'>' . $temp_val . '</a>'; } } } else { if ($module == "Leads" && $colname == "lastname" || $module == "Contacts" && $colname == "lastname") { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == "Calendar") { $actvity_type = $adb->query_result($list_result, $list_result_count, 'activitytype'); $actvity_type = $actvity_type != '' ? $actvity_type : $adb->query_result($list_result, $list_result_count, 'type'); if ($actvity_type == "Task") { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Task&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } else { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&activity_mode=Events&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } } elseif ($module == "Vendors") { $value = '<a href="index.php?action=DetailView&module=Vendors&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == "PriceBooks") { $value = '<a href="index.php?action=DetailView&module=PriceBooks&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == "SalesOrder") { $value = '<a href="index.php?action=DetailView&module=SalesOrder&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($module == 'Emails') { $value = $temp_val; } else { $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } } } elseif ($fieldname == 'expectedroi' || $fieldname == 'actualroi' || $fieldname == 'actualcost' || $fieldname == 'budgetcost' || $fieldname == 'expectedrevenue') { $rate = $user_info['conv_rate']; $value = convertFromDollar($temp_val, $rate); } elseif (($module == 'Invoice' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder') && ($fieldname == 'hdnGrandTotal' || $fieldname == 'hdnSubTotal' || $fieldname == 'txtAdjustment' || $fieldname == 'hdnDiscountAmount' || $fieldname == 'hdnS_H_Amount')) { $currency_info = getInventoryCurrencyInfo($module, $entity_id); $currency_id = $currency_info['currency_id']; $currency_symbol = $currency_info['currency_symbol']; $value = $currency_symbol . $temp_val; } else { $value = $temp_val; } } } // Mike Crowe Mod --------------------------------------------------------Make right justified and vtiger_currency value if (in_array($uitype, array(71, 72, 7, 9, 90))) { $value = '<span align="right">' . $value . '</div>'; } $log->debug("Exiting getValue method ..."); return $value; }
function getValue($uitype, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype, $returnset = '', $viewid = '') { global $log; global $app_strings; //changed by dingjianting on 2007-11-05 for php5.2.x $log->debug("Entering getValue() method ..."); global $adb, $current_user; if ($uitype == 10) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != "") { $value = ""; $module_entityname = ""; $modulename_lower = substr($fieldname, 0, -2); $modulename = ucfirst($modulename_lower); $modulesid = $modulename_lower . "id"; $tablename = "ec_" . $modulename_lower; $entityname = substr($fieldname, 0, -3) . "name"; $query = "SELECT {$entityname} FROM {$tablename} WHERE {$modulesid}='" . $temp_val . "' and deleted=0"; $fldmod_result = $adb->query($query); $rownum = $adb->num_rows($fldmod_result); if ($rownum > 0) { $value = $adb->query_result($fldmod_result, 0, $entityname); } } else { $value = ''; } } elseif ($uitype == 52 || $uitype == 53 || $uitype == 77) { $value = $adb->query_result($list_result, $list_result_count, 'user_name'); } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if (isValidDate($temp_val)) { $value = getDisplayDate($temp_val); } else { $value = ''; } } elseif ($uitype == 33) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = str_ireplace(' |##| ', ', ', $temp_val); } elseif ($uitype == 17) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = '<a href="http://' . $temp_val . '" target="_blank">' . $temp_val . '</a>'; } elseif ($uitype == 13 || $uitype == 104) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = '<a href="' . getComposeMailUrl($temp_val) . '" target="_blank">' . $temp_val . '</a>'; } elseif ($uitype == 56) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val == 1) { $value = 'yes'; } else { $value = 'no'; } //changed by dingjianting on 2006-10-15 for simplized chinese if (isset($app_strings[$value])) { $value = $app_strings[$value]; } } elseif ($uitype == 51 || $uitype == 73 || $uitype == 50) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != '') { $value = getAccountName($temp_val); } else { $value = ''; } } elseif ($uitype == 59) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != '') { $value = getProductName($temp_val); } else { $value = ''; } } elseif ($uitype == 76) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != '') { $value = getPotentialName($temp_val); } else { $value = ''; } } elseif ($uitype == 80) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val != '') { $value = getSoName($temp_val); } else { $value = ''; } } elseif ($uitype == 1004) { $value = $adb->query_result($list_result, $list_result_count, 'smcreatorid'); $value = getUserName($value); } elseif ($uitype == 1007) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = getApproveStatusById($temp_val); } elseif ($uitype == 1008) { $value = $adb->query_result($list_result, $list_result_count, 'approvedby'); $value = getUserName($value); } elseif ($uitype == 1004) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = getUserName($temp_val); } elseif ($uitype == 1007) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($temp_val == '1') { $value = $app_strings["already_approved"]; } elseif ($temp_val == '-1') { $value = $app_strings["unapproved"]; } elseif ($temp_val == '-2') { $value = $app_strings["Rejected"]; } else { $value = $app_strings["approving"]; } } elseif ($uitype == 1008) { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); $value = getUserName($temp_val); } else { $temp_val = $adb->query_result($list_result, $list_result_count, $fieldname); if ($fieldname != $focus->list_link_field) { $value = $temp_val; } else { if ($mode == "list") { $tabname = getParentTab(); $value = '<a href="index.php?action=DetailView&module=' . $module . '&record=' . $entity_id . '&parenttab=' . $tabname . '">' . $temp_val . '</a>'; } elseif ($mode == "search") { if ($popuptype == "specific") { $temp_val = str_replace("'", '\\"', $temp_val); $temp_val = popup_from_html($temp_val); //Added to avoid the error when select SO from Invoice through AjaxEdit if ($module == 'Salesorders') { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . br2nl($temp_val) . '","' . $_REQUEST['form'] . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'set_return_specific("' . $entity_id . '", "' . br2nl($temp_val) . '");\'>' . $temp_val . '</a>'; } } elseif ($popuptype == "detailview") { $temp_val = popup_from_html($temp_val); $focus->record_id = $_REQUEST['recordid']; if ($_REQUEST['return_module'] == "Calendar") { $value = '<a href="javascript:window.close();" id="calendarCont' . $entity_id . '" LANGUAGE=javascript onclick=\'add_data_to_relatedlist_incal("' . $entity_id . '","' . $temp_val . '");\'>' . $temp_val . '</a>'; } else { $value = '<a href="javascript:window.close();" onclick=\'add_data_to_relatedlist("' . $entity_id . '","' . $focus->record_id . '","' . $module . '");\'>' . $temp_val . '</a>'; } } elseif ($popuptype == "formname_specific") { $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_formname_specific("' . $_REQUEST['form'] . '", "' . $entity_id . '", "' . br2nl($temp_val) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod") { $row_id = $_REQUEST['curr_row']; //To get all the tax types and values and pass it to product details $tax_str = ''; $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . $unitprice . '", "' . $qty_stock . '","' . $tax_str . '","' . $row_id . '","' . $productcode . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prods") { $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); $qty_stock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $serialno = $adb->query_result($list_result, $list_result_count, 'serialno'); $temp_val = popup_from_html($temp_val); $value = $temp_val . '<input type="hidden" name="productname_' . $entity_id . '" id="productname_' . $entity_id . '" value="' . $temp_val . '"><input type="hidden" name="listprice_' . $entity_id . '" id="listprice_' . $entity_id . '" value="' . $unitprice . '"><input type="hidden" name="qtyinstock_' . $entity_id . '" id="qtyinstock_' . $entity_id . '" value="' . $qty_stock . '"><input type="hidden" id="productcode_' . $entity_id . '" name="productcode_' . $entity_id . '" value="' . $productcode . '"><input type="hidden" id="serialno_' . $entity_id . '" name="serialno_' . $entity_id . '" value="' . $serialno . '">'; } elseif ($popuptype == "salesorder_prod") { $row_id = $_REQUEST['curr_row']; $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); $temp_val = popup_from_html($temp_val); $producttype = $_REQUEST['producttype']; $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_so("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . $unitprice . '", "' . $row_id . '","' . $producttype . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod_po") { $row_id = $_REQUEST['curr_row']; $unitprice = $adb->query_result($list_result, $list_result_count, 'unit_price'); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_po("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . $unitprice . '", "' . $productcode . '","' . $row_id . '"); \'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod_noprice") { $row_id = $_REQUEST['curr_row']; $temp_val = popup_from_html($temp_val); $qtyinstock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_noprice("' . $entity_id . '", "' . br2nl($temp_val) . '","' . $row_id . '","' . $qtyinstock . '","' . $productcode . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "inventory_prod_check") { $row_id = $_REQUEST['curr_row']; $temp_val = popup_from_html($temp_val); $productcode = $adb->query_result($list_result, $list_result_count, 'productcode'); $usageunit = $adb->query_result($list_result, $list_result_count, 'usageunit'); $qtyinstock = $adb->query_result($list_result, $list_result_count, 'qtyinstock'); $value = '<a href="javascript:window.close();" onclick=\'set_return_inventory_check("' . $entity_id . '", "' . br2nl($temp_val) . '","' . $row_id . '","' . $productcode . '","' . $usageunit . '","' . $qtyinstock . '"); \'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . br2nl($acct_focus->column_fields['bill_street']) . '", "' . br2nl($acct_focus->column_fields['ship_street']) . '", "' . br2nl($acct_focus->column_fields['bill_city']) . '", "' . br2nl($acct_focus->column_fields['ship_city']) . '", "' . br2nl($acct_focus->column_fields['bill_state']) . '", "' . br2nl($acct_focus->column_fields['ship_state']) . '", "' . br2nl($acct_focus->column_fields['bill_code']) . '", "' . br2nl($acct_focus->column_fields['ship_code']) . '", "' . br2nl($acct_focus->column_fields['bill_country']) . '", "' . br2nl($acct_focus->column_fields['ship_country']) . '","' . br2nl($acct_focus->column_fields['bill_pobox']) . '", "' . br2nl($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_contact_account_address") { require_once 'modules/Accounts/Accounts.php'; $acct_focus = new Accounts(); $acct_focus->retrieve_entity_info($entity_id, "Accounts"); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_contact_address("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . br2nl($acct_focus->column_fields['bill_street']) . '", "' . br2nl($acct_focus->column_fields['ship_street']) . '", "' . br2nl($acct_focus->column_fields['bill_city']) . '", "' . br2nl($acct_focus->column_fields['ship_city']) . '", "' . br2nl($acct_focus->column_fields['bill_state']) . '", "' . br2nl($acct_focus->column_fields['ship_state']) . '", "' . br2nl($acct_focus->column_fields['bill_code']) . '", "' . br2nl($acct_focus->column_fields['ship_code']) . '", "' . br2nl($acct_focus->column_fields['bill_country']) . '", "' . br2nl($acct_focus->column_fields['ship_country']) . '","' . br2nl($acct_focus->column_fields['bill_pobox']) . '", "' . br2nl($acct_focus->column_fields['ship_pobox']) . '");\'>' . $temp_val . '</a>'; } elseif ($popuptype == "specific_potential_account_address") { $acntid = $adb->query_result($list_result, $list_result_count, "accountid"); if ($acntid != "") { //require_once('modules/Accounts/Accounts.php'); //$acct_focus = new Accounts(); //$acct_focus->retrieve_entity_info($acntid,"Accounts"); $account_name = getAccountName($acntid); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return_address("' . $entity_id . '", "' . br2nl($temp_val) . '", "' . $acntid . '", "' . br2nl($account_name) . '");\'>' . $temp_val . '</a>'; } else { $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" >' . $temp_val . '</a>'; } } elseif ($popuptype == "set_return_emails") { $name = $adb->query_result($list_result, $list_result_count, "lastname"); $emailaddress = $adb->query_result($list_result, $list_result_count, "email"); if ($emailaddress == '') { $emailaddress = $adb->query_result($list_result, $list_result_count, "msn"); } $where = isset($_REQUEST['where']) ? $_REQUEST['where'] : ""; $value = '<a href="javascript:;" onclick=\'return set_return_emails("' . $where . '","' . $name . '","' . $emailaddress . '"); \'>' . $name . '</a>'; } elseif ($popuptype == "set_return_mobiles") { //$firstname=$adb->query_result($list_result,$list_result_count,"first_name"); $contactname = $adb->query_result($list_result, $list_result_count, "lastname"); $mobile = $adb->query_result($list_result, $list_result_count, "mobile"); //changed by dingjianting on 2006-11-9 for simplized chinese $value = '<a href="#" onclick=\'return set_return_mobiles(' . $entity_id . ',"' . $contactname . '","' . $mobile . '"); \'>' . $contactname . '</a>'; } elseif ($popuptype == "set_return_usermobiles") { //$firstname=$adb->query_result($list_result,$list_result_count,"first_name"); $lastname = $adb->query_result($list_result, $list_result_count, "last_name"); $mobile = $adb->query_result($list_result, $list_result_count, "phone_mobile"); //changed by dingjianting on 2006-11-9 for simplized chinese $value = '<a href="#" onclick=\'return set_return_mobiles(' . $entity_id . ',"' . $lastname . '","' . $mobile . '"); \'>' . $lastname . '</a>'; } else { $temp_val = str_replace("'", '\\"', $temp_val); $temp_val = popup_from_html($temp_val); $value = '<a href="javascript:window.close();" onclick=\'set_return("' . $entity_id . '", "' . br2nl($temp_val) . '");\'>' . $temp_val . '</a>'; } } } } $log->debug("Exiting getValue method ..."); return $value; }
/** * Function to get Pending/Upcoming activities * @param integer $mode - number to differentiate upcoming and pending activities * return array $values - activities record in array format */ function getPendingActivities($mode, $view = '') { global $log; $log->debug("Entering getPendingActivities() method ..."); require_once 'data/Tracker.php'; require_once 'include/utils/utils.php'; require_once 'user_privileges/default_module_view.php'; global $currentModule; global $singlepane_view; global $theme; global $focus; global $action; global $adb; global $app_strings; global $current_language; global $current_user; $current_module_strings = return_module_language($current_language, 'Calendar'); $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; if ($_REQUEST['activity_view'] == '') { $activity_view = 'today'; } else { $activity_view = vtlib_purify($_REQUEST['activity_view']); } $today = date("Y-m-d", time()); if ($view == 'today') { $upcoming_condition = " AND (date_start = '{$today}' OR vtiger_recurringevents.recurringdate = '{$today}')"; $pending_condition = " AND (due_date = '{$today}' OR vtiger_recurringevents.recurringdate = '{$today}')"; } else { if ($view == 'all') { $upcoming_condition = " AND (date_start >= '{$today}' OR vtiger_recurringevents.recurringdate >= '{$today}')"; $pending_condition = " AND (due_date <= '{$today}' OR vtiger_recurringevents.recurringdate <= '{$today}')"; } } if ($mode != 1) { $list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity." . "setype, vtiger_recurringevents.recurringdate, vtiger_activity.activityid, " . "vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date," . "from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=" . "vtiger_activity.activityid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = " . "vtiger_crmentity.smownerid left outer join vtiger_recurringevents on " . "vtiger_recurringevents.activityid=vtiger_activity.activityid"; $list_query .= getNonAdminAccessControlQuery('Calendar', $current_user); $list_query .= " WHERE vtiger_crmentity.deleted=0 and vtiger_activity.activitytype not in " . "('Emails') AND ( vtiger_activity.status is NULL OR vtiger_activity.status not in" . "('Completed','Deferred')) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity." . "eventstatus not in ('Held','Not Held') )" . $upcoming_condition; } else { $list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity" . "setype, vtiger_recurringevents.recurringdate, vtiger_activity.activityid, vtiger_activity" . ".activitytype, vtiger_activity.date_start, vtiger_activity.due_date, from vtiger_activity" . "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid " . "LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid " . "left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=" . "vtiger_activity.activityid"; $list_query .= getNonAdminAccessControlQuery('Calendar', $current_user); $list_query .= "WHERE vtiger_crmentity.deleted=0 and (vtiger_activity." . "activitytype not in ('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity." . "status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR " . "vtiger_activity.eventstatus not in ('Held','Not Held')) " . $pending_condition; $list_query .= " GROUP BY vtiger_activity.activityid"; $list_query .= " ORDER BY date_start,time_start ASC"; $res = $adb->query($list_query); $noofrecords = $adb->num_rows($res); $open_activity_list = array(); $noofrows = $adb->num_rows($res); if (count($res) > 0) { for ($i = 0; $i < $noofrows; $i++) { $open_activity_list[] = array('name' => $adb->query_result($res, $i, 'subject'), 'id' => $adb->query_result($res, $i, 'activityid'), 'type' => $adb->query_result($res, $i, 'activitytype'), 'module' => $adb->query_result($res, $i, 'setype'), 'date_start' => getDisplayDate($adb->query_result($res, $i, 'date_start')), 'due_date' => getDisplayDate($adb->query_result($res, $i, 'due_date')), 'recurringdate' => getDisplayDate($adb->query_result($res, $i, 'recurringdate')), 'priority' => $adb->query_result($res, $i, 'priority')); } } $title = array(); $title[] = $view; $title[] = 'myUpcoPendAct.gif'; $title[] = 'home_myact'; $title[] = 'showActivityView'; $title[] = 'MyUpcumingFrm'; $title[] = 'activity_view'; $header = array(); $header[] = $current_module_strings['LBL_LIST_SUBJECT']; $header[] = 'Type'; $return_url = "&return_module={$currentModule}&return_action=DetailView&return_id=" . (is_object($focus) ? $focus->id : ""); $oddRow = true; $entries = array(); foreach ($open_activity_list as $event) { $recur_date = preg_replace('/--/', '', $event['recurringdate']); if ($recur_date != "") { $event['date_start'] = $event['recurringdate']; } $font_color_high = "color:#00DD00;"; $font_color_medium = "color:#DD00DD;"; switch ($event['priority']) { case 'High': $font_color = $font_color_high; break; case 'Medium': $font_color = $font_color_medium; break; default: $font_color = ''; } if ($event['type'] != 'Task' && $event['type'] != 'Emails' && $event['type'] != '') { $activity_type = 'Events'; } else { $activity_type = 'Task'; } } $entries[$event['id']] = array('0' => '<a href="index.php?action=DetailView&module=' . $event["module"] . '&activity_mode=' . $activity_type . '&record=' . $event["id"] . '' . $return_url . '" style="' . $font_color . ';">' . $event["name"] . '</a>', 'IMAGE' => '<IMG src="' . $image_path . $event["type"] . 's.gif">'); } $values = array('noofactivities' => $noofrecords, 'Title' => $title, 'Header' => $header, 'Entries' => $entries); $log->debug("Exiting getPendingActivities method ..."); return $values; }
global $currentModule; global $app_strings; global $app_list_strings; global $moduleList; global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; require_once $theme_path . 'layout_utils.php'; $smarty = new CRMSmarty(); $header_array = getHeaderArray(); $smarty->assign("HEADERS", $header_array); $smarty->assign("THEME", $theme); $smarty->assign("IMAGEPATH", $image_path); $smarty->assign("APP", $app_strings); $smarty->assign("MODULE_NAME", $currentModule); $smarty->assign("DATE", getDisplayDate(date("Y-m-d H:i"))); $smarty->assign("CURRENT_USER", $current_user->user_name); $smarty->assign("CURRENT_USER_ID", $current_user->id); $smarty->assign("MODULELISTS", $app_list_strings['moduleList']); $smarty->assign("CATEGORY", getParentTab()); //$smarty->assign("ANNOUNCEMENT",get_announcements()); $module_path = "modules/" . $currentModule . "/"; ///auth $nowdate = date("Ymd"); $auth = md5($nowdate . $current_user->email2); $smarty->assign("AUTH", $auth); //NEW taobao if ($_REQUEST['ac'] == 'logout') { $_SESSION['topsession'] = ''; $_SESSION['nick'] = ''; //echo "<script>window.close();</script>";
/** Function used to get the Payments Stage history of the CobroPago * @param $id - cobropagoid * return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are array which contains all the column values of an row */ function get_payment_history($id) { global $log; $log->debug("Entering get_stage_history(" . $id . ") method ..."); global $adb; global $mod_strings; global $app_strings; $query = 'select vtiger_potstagehistory.*, vtiger_cobropago.reference from vtiger_potstagehistory inner join vtiger_cobropago on vtiger_cobropago.cobropagoid = vtiger_potstagehistory.cobropagoid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_cobropago.cobropagoid where vtiger_crmentity.deleted = 0 and vtiger_cobropago.cobropagoid = ?'; $result = $adb->pquery($query, array($id)); $noofrows = $adb->num_rows($result); $header[] = $app_strings['LBL_AMOUNT']; $header[] = $app_strings['LBL_SALES_STAGE']; $header[] = $app_strings['LBL_PROBABILITY']; $header[] = $app_strings['LBL_CLOSE_DATE']; $header[] = $app_strings['LBL_LAST_MODIFIED']; //Getting the field permission for the current user. 1 - Not Accessible, 0 - Accessible //Sales Stage, Expected Close Dates are mandatory fields. So no need to do security check to these fields. global $current_user; //If field is accessible then getFieldVisibilityPermission function will return 0 else return 1 $amount_access = getFieldVisibilityPermission('CobroPago', $current_user->id, 'amount') != '0' ? 1 : 0; $probability_access = getFieldVisibilityPermission('CobroPago', $current_user->id, 'probability') != '0' ? 1 : 0; $picklistarray = getAccessPickListValues('CobroPago'); $potential_stage_array = $picklistarray['sales_stage']; //- ==> picklist field is not permitted in profile //Not Accessible - picklist is permitted in profile but picklist value is not permitted $error_msg = 'Not Accessible'; while ($row = $adb->fetch_array($result)) { $entries = array(); $entries[] = $amount_access != 1 ? $row['amount'] : 0; $entries[] = in_array($row['stage'], $potential_stage_array) ? $row['stage'] : $error_msg; $entries[] = $probability_access != 1 ? $row['probability'] : 0; $entries[] = getDisplayDate($row['closedate']); $entries[] = getDisplayDate($row['lastmodified']); $entries_list[] = $entries; } $return_data = array('header' => $header, 'entries' => $entries_list); $log->debug("Exiting get_stage_history method ..."); return $return_data; }
function create_contact1($user_name, $first_name, $last_name, $email_address, $account_name, $salutation, $title, $phone_mobile, $reports_to, $primary_address_street, $primary_address_city, $primary_address_state, $primary_address_postalcode, $primary_address_country, $alt_address_city, $alt_address_street, $alt_address_state, $alt_address_postalcode, $alt_address_country, $office_phone, $home_phone, $other_phone, $fax, $department, $birthdate, $assistant_name, $assistant_phone, $description = '') { global $adb, $log; global $current_user; require_once 'modules/Users/Users.php'; $seed_user = new Users(); $user_id = $seed_user->retrieve_user_id($user_name); $current_user = $seed_user; $current_user->retrieve_entity_info($user_id, 'Users'); require_once 'modules/Contacts/Contacts.php'; if (isPermitted("Contacts", "EditView") == "yes") { $contact = new Contacts(); $contact->column_fields[firstname] = $first_name; $contact->column_fields[lastname] = $last_name; //$contact->column_fields[account_id]=retrieve_account_id($account_name,$user_id);// NULL value is not supported NEED TO FIX $contact->column_fields[salutation] = $salutation; // EMAIL IS NOT ADDED $contact->column_fields[title] = $title; $contact->column_fields[email] = $email_address; $contact->column_fields[mobile] = $phone_mobile; //$contact->column_fields[reports_to_id] =retrievereportsto($reports_to,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP $contact->column_fields[mailingstreet] = $primary_address_street; $contact->column_fields[mailingcity] = $primary_address_city; $contact->column_fields[mailingcountry] = $primary_address_country; $contact->column_fields[mailingstate] = $primary_address_state; $contact->column_fields[mailingzip] = $primary_address_postalcode; $contact->column_fields[otherstreet] = $alt_address_street; $contact->column_fields[othercity] = $alt_address_city; $contact->column_fields[othercountry] = $alt_address_country; $contact->column_fields[otherstate] = $alt_address_state; $contact->column_fields[otherzip] = $alt_address_postalcode; $contact->column_fields[assigned_user_id] = $user_id; // new Fields $contact->column_fields[phone] = $office_phone; $contact->column_fields[homephone] = $home_phone; $contact->column_fields[otherphone] = $other_phone; $contact->column_fields[fax] = $fax; $contact->column_fields[department] = $department; $contact->column_fields[birthday] = getDisplayDate($birthdate); $contact->column_fields[assistant] = $assistant_name; $contact->column_fields[assistantphone] = $assistant_phone; $contact->column_fields[description] = $description; $contact->save("Contacts"); if ($contact->id != '') { return 'Contact added successfully'; } else { return "Contact creation failed. Try again"; } } else { return $accessDenied; } }
function formatDate($value) { return getDisplayDate($value); }
} $advfilterlist = $oCustomView->getAdvFilterByCvid($recordid); $log->info('CustomView :: Successfully got Advanced Filter for the Viewid' . $recordid, 'info'); for ($i = 1; $i < 6; $i++) { $advfilterhtml = getAdvCriteriaHTML($advfilterlist[$i - 1]["comparator"]); $advcolumnhtml = getByModule_ColumnsHTML($cv_module, $modulecollist, $advfilterlist[$i - 1]["columnname"]); $smarty->assign("FOPTION" . $i, $advfilterhtml); $smarty->assign("BLOCK" . $i, $advcolumnhtml); $col = explode(":", $advfilterlist[$i - 1]["columnname"]); $temp_val = explode(",", $advfilterlist[$i - 1]["value"]); $and_text = " " . $mod_strings['LBL_AND']; 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 (trim($temp_val[$x] != "")) { $val[$x] = getDisplayDate(trim($temp_val[$x])); } } $advfilterlist[$i - 1]["value"] = implode(", ", $val); $and_text = "<em old='(yyyy-mm-dd)'>(" . $current_user->date_format . ")</em> " . $mod_strings['LBL_AND']; } $smarty->assign("VALUE" . $i, $advfilterlist[$i - 1]["value"]); $smarty->assign("AND_TEXT" . $i, $and_text); } $smarty->assign("STDFILTERCOLUMNS", $stdfiltercolhtml); $smarty->assign("STDCOLUMNSCOUNT", count($stdfiltercolhtml)); $smarty->assign("STDFILTERCRITERIA", $stdfilterhtml); $smarty->assign("STDFILTER_JAVASCRIPT", $stdfilterjs); $smarty->assign("MANDATORYCHECK", implode(",", array_unique($oCustomView->mandatoryvalues))); $smarty->assign("SHOWVALUES", implode(",", $oCustomView->showvalues)); $smarty->assign("EXIST", "true");
} $BLOCK1 = getPrimaryStdFilterHTML($oReport->primodule, $oReport->stdselectedcolumn); $BLOCK1 .= getSecondaryStdFilterHTML($oReport->secmodule, $oReport->stdselectedcolumn); //added to fix the ticket #5117 $selectedcolumnvalue = '"' . $oReport->stdselectedcolumn . '"'; if (!$is_admin && isset($oReport->stdselectedcolumn) && strpos($BLOCK1, $selectedcolumnvalue) === false) { $BLOCK1 .= "<option selected value='Not Accessible'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</option>"; } $report_std_filter->assign("BLOCK1_STD", $BLOCK1); $BLOCKJS = $oReport->getCriteriaJS(); $report_std_filter->assign("BLOCKJS_STD", $BLOCKJS); $BLOCKCRITERIA = $oReport->getSelectedStdFilterCriteria($oReport->stdselectedfilter); $report_std_filter->assign("BLOCKCRITERIA_STD", $BLOCKCRITERIA); if (isset($oReport->startdate) && isset($oReport->enddate)) { $report_std_filter->assign("STARTDATE_STD", getDisplayDate($oReport->startdate)); $report_std_filter->assign("ENDDATE_STD", getDisplayDate($oReport->enddate)); } else { $report_std_filter->assign("STARTDATE_STD", $oReport->startdate); $report_std_filter->assign("ENDDATE_STD", $oReport->enddate); } } /** Function to get the HTML strings for the primarymodule standard filters * @ param $module : Type String * @ param $selected : Type String(optional) * This Returns a HTML combo srings */ function getPrimaryStdFilterHTML($module, $selected = "") { global $app_list_strings; global $ogReport; global $current_language;
/** * function to get pending activities for today * @param integer $maxval - the maximum number of records to display * @param integer $calCnt - returns the count query if this is set * return array $values - activities record in array format */ function homepage_getPendingActivities($maxval, $calCnt) { require_once "data/Tracker.php"; require_once "include/utils/utils.php"; require_once 'include/utils/CommonUtils.php'; global $adb; global $current_user; $today = date("Y-m-d", time()); $pending_condition = " AND (due_date = '{$today}' OR vtiger_recurringevents.recurringdate = '{$today}')"; $list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity." . "setype, vtiger_recurringevents.recurringdate, vtiger_activity.* from vtiger_activity " . "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid LEFT " . "JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid left outer join " . "vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid" . ($list_query .= getNonAdminAccessControlQuery('Calendar', $current_user)); $list_query .= "WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype not in " . "('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity.status not in " . "('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR vtiger_activity." . "eventstatus not in ('Held','Not Held')) " . $pending_condition; $list_query .= " GROUP BY vtiger_activity.activityid"; $list_query .= " ORDER BY date_start,time_start ASC"; $list_query .= " limit {$maxval}"; $res = $adb->query($list_query); $noofrecords = $adb->num_rows($res); if ($calCnt == 'calculateCnt') { return $noofrecords; } $open_activity_list = array(); $noofrows = $adb->num_rows($res); if (count($res) > 0) { for ($i = 0; $i < $noofrows; $i++) { $open_activity_list[] = array('name' => $adb->query_result($res, $i, 'subject'), 'id' => $adb->query_result($res, $i, 'activityid'), 'type' => $adb->query_result($res, $i, 'activitytype'), 'module' => $adb->query_result($res, $i, 'setype'), 'date_start' => getDisplayDate($adb->query_result($res, $i, 'date_start')), 'due_date' => getDisplayDate($adb->query_result($res, $i, 'due_date')), 'recurringdate' => getDisplayDate($adb->query_result($res, $i, 'recurringdate')), 'priority' => $adb->query_result($res, $i, 'priority')); } } $values = getActivityEntries($open_activity_list); $values['ModuleName'] = 'Calendar'; $values['search_qry'] = "&action=ListView&from_homepage=pending_activities"; return $values; }
// billing Address $billPositions = array("10", "51", "61"); if (trim($bill_street) != '') { $billText = $bill_street . "\n"; } if (trim($bill_city) != '') { $billText .= $bill_city . ", "; } if (trim($bill_state) != '' || trim($bill_code) != '') { $billText .= $bill_state . " " . $bill_code . "\n"; } $billText .= $bill_country; $pdf->addTextBlock($app_strings["Billing Address"] . ":", $billText, $billPositions); // ********** End Addresses ****************** /* ******** Begin Invoice Data ************************ */ // issue date block $issueBlock = array("80", "37"); $pdf->addRecBlock(getDisplayDate(date("Y-m-d")), $app_strings["Issue Date"], $issueBlock); // due date block $dueBlock = array("81", "52"); $pdf->addRecBlock($valid_till, $app_strings["Due Date"], $dueBlock); // terms block $termBlock = array("10", "67"); $pdf->addRecBlock($vendor_name, $app_strings["Vendor Name"], $termBlock); // Contact Name block $conBlock = array("79", "67"); $pdf->addRecBlock($contact_name, $app_strings["Contact Name"], $conBlock); // vtiger_invoice number block $invBlock = array("145", "65"); $pdf->addRecBlock($po_no, $app_strings["PO Number"], $invBlock); /* ************ End Invoice Data ************************ */
/** This function returns the ec_field details for a given ec_fieldname. * Param $uitype - UI type of the ec_field * Param $fieldname - Form ec_field name * Param $fieldlabel - Form ec_field label name * Param $maxlength - maximum length of the ec_field * Param $col_fields - array contains the ec_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $module_name - module name * Return type is an array */ function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $mandatory = 0, $typeofdata = "") { global $log; $log->debug("Entering getOutputHtml() method ..."); global $adb, $log; global $theme; global $mod_strings; global $app_strings; global $current_user; global $noof_group_rows; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //$fieldlabel = from_html($fieldlabel); $fieldvalue = array(); $final_arr = array(); $value = $col_fields[$fieldname]; $custfld = ''; $ui_type[] = $uitype; $editview_fldname[] = $fieldname; if ($generatedtype == 2) { $mod_strings[$fieldlabel] = $fieldlabel; } if (!isset($mod_strings[$fieldlabel])) { $mod_strings[$fieldlabel] = $fieldlabel; } if ($uitype == 5) { if ($value == '') { if ($mandatory == 1) { $disp_value = getNewDisplayDate(); } } else { $disp_value = getDisplayDate($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $disp_value; } elseif ($uitype == 15 || $uitype == 16 || $uitype == 111) { $editview_label[] = $mod_strings[$fieldlabel]; //changed by dingjianting on 2007-10-3 for cache pickListResult $key = "picklist_array_" . $fieldname; $picklist_array = getSqlCacheData($key); if (!$picklist_array) { $pick_query = "select colvalue from ec_picklist where colname='" . $fieldname . "' order by sequence asc"; $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = $row['colvalue']; } setSqlCacheData($key, $picklist_array); } //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; foreach ($picklist_array as $pickListValue) { if ($value == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == '1021' || $uitype == '1022' || $uitype == '1023') { $typearr = explode("::", $typeofdata); $multifieldid = $typearr[1]; $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = getMultiFieldEditViewValue($multifieldid, $uitype, $col_fields); $fieldvalue[] = $multifieldid; //print_r($fieldvalue); } elseif ($uitype == 10) { $query = "SELECT ec_entityname.* FROM ec_crmentityrel inner join ec_entityname on ec_entityname.modulename=ec_crmentityrel.relmodule WHERE ec_crmentityrel.module='" . $module_name . "' and ec_entityname.entityidfield='" . $fieldname . "'"; $fldmod_result = $adb->query($query); $rownum = $adb->num_rows($fldmod_result); if ($rownum > 0) { $rel_modulename = $adb->query_result($fldmod_result, 0, 'modulename'); $rel_tablename = $adb->query_result($fldmod_result, 0, 'tablename'); $rel_entityname = $adb->query_result($fldmod_result, 0, 'fieldname'); $rel_entityid = $adb->query_result($fldmod_result, 0, 'entityidfield'); } if ($value != '') { $module_entityname = getEntityNameForTen($rel_tablename, $rel_entityname, $fieldname, $value); } elseif (isset($_REQUEST[$fieldname]) && $_REQUEST[$fieldname] != '') { if ($_REQUEST['module'] == $rel_modulename) { $module_entityname = ''; } else { $value = $_REQUEST[$fieldname]; $module_entityname = getEntityNameForTen($rel_tablename, $rel_entityname, $fieldname, $value); } } if (isset($app_strings[$fieldlabel])) { $editview_label[] = $app_strings[$fieldlabel]; } elseif (isset($mod_strings[$fieldlabel])) { $editview_label[] = $mod_strings[$fieldlabel]; } else { $editview_label[] = $fieldlabel; } $fieldvalue[] = $module_entityname; $fieldvalue[] = $value; $fieldvalue[] = $rel_entityname; $fieldvalue[] = $rel_modulename; } elseif ($uitype == 17) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 85) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 86) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 87) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 88) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 89) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 33) { $pick_query = "select colvalue from ec_picklist where colname='" . $fieldname . "' order by sequence asc"; $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = $row['colvalue']; } $editview_label[] = $mod_strings[$fieldlabel]; $mulsel = "select colvalue from ec_picklist where colname='" . $fieldname . "' order by sequence asc"; $multiselect_result = $adb->query($mulsel); $noofoptions = $adb->num_rows($multiselect_result); $options = array(); $found = false; $valur_arr = explode(' |##| ', $value); for ($j = 0; $j < $noofoptions; $j++) { $multiselect_combo = $adb->query_result($multiselect_result, $j, "colvalue"); if (in_array($multiselect_combo, $valur_arr)) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($multiselect_combo => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == 19 || $uitype == 20) { if (isset($_REQUEST['body'])) { $value = $_REQUEST['body']; } $editview_label[] = $mod_strings[$fieldlabel]; //$value = to_html($value); //$value = htmlspecialchars($value, ENT_QUOTES, "UTF-8"); $fieldvalue[] = $value; } elseif ($uitype == 21 || $uitype == 24) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 22) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 52) { $editview_label[] = $mod_strings[$fieldlabel]; global $current_user; if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } $combo_lbl_name = 'assigned_user_id'; if ($fieldlabel == 'Assigned To') { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } else { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } $fieldvalue[] = $users_combo; } elseif ($uitype == 77) { $editview_label[] = $mod_strings[$fieldlabel]; global $current_user; if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } $combo_lbl_name = 'assigned_user_id'; $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); $fieldvalue[] = $users_combo; } elseif ($uitype == 53) { $editview_label[] = $mod_strings[$fieldlabel]; global $current_user; if ($value != '' && $value != 0) { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if ($fieldlabel == 'Assigned To') { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } else { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } $fieldvalue[] = $users_combo; } elseif ($uitype == 1004) { if (isset($mod_strings[$fieldlabel])) { $editview_label[] = $mod_strings[$fieldlabel]; } else { $editview_label[] = $fieldlabel; } if (empty($value)) { global $current_user; $value = $current_user->id; } $fieldvalue[] = getUserName($value); } elseif ($uitype == 1008) { if (isset($mod_strings[$fieldlabel])) { $editview_label[] = $mod_strings[$fieldlabel]; } else { $editview_label[] = $fieldlabel; } if (empty($value)) { global $current_user; $value = $current_user->id; } $fieldvalue[] = getUserName($value); } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_name = ""; /*$convertmode = ""; if(isset($_REQUEST['convertmode'])) { $convertmode = $_REQUEST['convertmode']; } if($convertmode != 'update_quote_val' && $convertmode != 'update_so_val') { if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') $value = $_REQUEST['account_id']; }*/ if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $value = $_REQUEST['account_id']; } if ($value != '') { $account_name = getAccountName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $account_name; $fieldvalue[] = $value; } elseif ($uitype == 54) { $options = array(); if ($value == "") { $key = "currentuser_group_" . $current_user->id; $currentuser_group = getSqlCacheData($key); if (!$currentuser_group) { $query = "select ec_groups.groupname from ec_groups left join ec_users2group on ec_users2group.groupid=ec_groups.groupid where ec_users2group.userid='" . $current_user->id . "' and ec_users2group.groupid!=0"; $result = $adb->query($query); $noofrows = $adb->num_rows($result); if ($noofrows > 0) { $currentuser_group = $adb->query_result($result, 0, "groupname"); } setSqlCacheData($key, $currentuser_group); } $value = $currentuser_group; } $key = "picklist_array_group"; $picklist_array = getSqlCacheData($key); if (!$picklist_array) { $pick_query = "select * from ec_groups order by groupid"; $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = $row["groupname"]; } setSqlCacheData($key, $picklist_array); } $editview_label[] = $mod_strings[$fieldlabel]; foreach ($picklist_array as $pickListValue) { if ($value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == 59) { if ($value != '') { $product_name = getProductName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $product_name; $fieldvalue[] = $value; } elseif ($uitype == 64) { $editview_label[] = $mod_strings[$fieldlabel]; $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); $fieldvalue[] = $value; } elseif ($uitype == 56) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 57) { $accountid = $col_fields['account_id']; if (empty($accountid)) { $convertmode = ""; if (isset($_REQUEST['convertmode'])) { $convertmode = $_REQUEST['convertmode']; } if ($convertmode != 'update_quote_val' && $convertmode != 'update_so_val') { if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $accountid = $_REQUEST['account_id']; } } } $contact_name = ''; // if(trim($value) != '') // { // $contact_name = getContactName($value); // } // elseif(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') // { // if(isset($_REQUEST['module']) && $_REQUEST['module'] == 'Contacts' && $fieldname = 'contact_id') // { // $contact_name = ''; // } // else // { // $value = $_REQUEST['contact_id']; // $contact_name = getContactName($value); // } // // } if (trim($value) == '') { if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) { } else { $value = $_REQUEST['contact_id']; } } $contactopts = getContactOptions($accountid, $value); //Checking for contacts duplicate $editview_label[] = $mod_strings[$fieldlabel]; // $fieldvalue[] = $contact_name; $fieldvalue[] = $contactopts; $fieldvalue[] = $value; } elseif ($uitype == 76) { if ($value != '') { $potential_name = getPotentialName($value); } elseif (isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') { $value = $_REQUEST['potental_id']; $potential_name = getPotentialName($value); } elseif (isset($_REQUEST['potentialid']) && $_REQUEST['potentialid'] != '') { $value = $_REQUEST['potentalid']; $potential_name = getPotentialName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $potential_name; $fieldvalue[] = $value; } elseif ($uitype == 80) { if ($value != '') { $salesorder_name = getSoName($value); } elseif (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') { $value = $_REQUEST['salesorder_id']; $salesorder_name = getSoName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $salesorder_name; $fieldvalue[] = $value; } elseif ($uitype == 101) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = getUserName($value); $fieldvalue[] = $value; } else { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } $final_arr[] = $ui_type; $final_arr[] = $editview_label; $final_arr[] = $editview_fldname; $final_arr[] = $fieldvalue; $log->debug("Exiting getOutputHtml method ..."); return $final_arr; }
public function onBeforeDisplayCheckoutFinish(&$text, &$order_id) { $user = JFactory::getUser(); if ($user->id > 0) { return true; } // Скрытие текста $text = ' '; // Показ гостю копии страницы из личного кабинета // $dispatcher = JDispatcher::getInstance(); $jshopConfig = JSFactory::getConfig(); $lang = JSFactory::getLang(); $order = JTable::getInstance('order', 'jshop'); $order->load($order_id); $order->items = $order->getAllItems(); $order->weight = $order->getWeightItems(); $order->status_name = $order->getStatus(); $order->history = $order->getHistory(); $order->order_tax_list = $order->getTaxExt(); $order->birthday = getDisplayDate($order->birthday, $jshopConfig->field_birthday_format); $order->d_birthday = getDisplayDate($order->d_birthday, $jshopConfig->field_birthday_format); $name = $lang->get("name"); $description = $lang->get("description"); $pm_method = JTable::getInstance('paymentMethod', 'jshop'); $pm_method->load($order->payment_method_id); $order->payment_name = $pm_method->{$name}; if ($pm_method->show_descr_in_email) { $order->payment_description = $pm_method->{$description}; } else { $order->payment_description = ""; } $country = JTable::getInstance('country', 'jshop'); $country->load($order->country); $field_country_name = $lang->get("name"); $order->country = $country->{$field_country_name}; $d_country = JTable::getInstance('country', 'jshop'); $d_country->load($order->d_country); $field_country_name = $lang->get("name"); $order->d_country = $d_country->{$field_country_name}; $jshopConfig->user_field_client_type[0] = ""; $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type]; $order->delivery_time_name = ''; $order->delivery_date_f = ''; if ($jshopConfig->show_delivery_time_checkout) { $deliverytimes = JSFactory::getAllDeliveryTime(); $order->delivery_time_name = $deliverytimes[$order->delivery_times_id]; if ($order->delivery_time_name == "") { $order->delivery_time_name = $order->delivery_time; } } if ($jshopConfig->show_delivery_date && !datenull($order->delivery_date)) { $order->delivery_date_f = formatdate($order->delivery_date); } if ($order->weight == 0 && $jshopConfig->hide_weight_in_cart_weight0) { $jshopConfig->show_weight_order = 0; } $jshopConfig->order_send_pdf_client = 0; $show_percent_tax = 0; if (count($order->order_tax_list) > 1 || $jshopConfig->show_tax_in_product) { $show_percent_tax = 1; } if ($jshopConfig->hide_tax) { $show_percent_tax = 0; } $hide_subtotal = 0; if (($jshopConfig->hide_tax || count($order->order_tax_list) == 0) && $order->order_discount == 0 && $order->order_payment == 0 && $jshopConfig->without_shipping) { $hide_subtotal = 1; } $text_total = _JSHOP_ENDTOTAL; if (($jshopConfig->show_tax_in_product || $jshopConfig->show_tax_product_in_cart) && count($order->order_tax_list) > 0) { $text_total = _JSHOP_ENDTOTAL_INKL_TAX; } $tmp_fields = $jshopConfig->getListFieldsRegister(); $config_fields = $tmp_fields["address"]; $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('address'); $className = 'JshoppingViewOrder'; $view_name = "order"; if (!class_exists($className)) { require_once JPATH_COMPONENT . '/views/' . $view_name . '/view.html.php'; } $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name); $view = new $className($view_config); $view->setLayout("order"); $view->assign('order', $order); $view->assign('config', $jshopConfig); $view->assign('text_total', $text_total); $view->assign('show_percent_tax', $show_percent_tax); $view->assign('hide_subtotal', $hide_subtotal); $view->assign('image_path', $jshopConfig->live_path . "images"); $view->assign('config_fields', $config_fields); $view->assign('count_filed_delivery', $count_filed_delivery); $view->assign('allow_cancel', false); $view->display(); return true; }
echo $cal_dateformat; ?> ", showsTime : false, button : "date_start_trigger", singleClick : true, step : 1 }); Calendar.setup ({ inputField : "date_end", ifFormat : "<?php echo $cal_dateformat; ?> ", showsTime : false, button : "date_end_trigger", singleClick : true, step : 1 }); </script> <?php } else { if (file_exists($tmp_dir . $cache_file_name)) { $file_date = getDisplayDate(date('Y-m-d H:i', filemtime($tmp_dir . $cache_file_name))); } else { $file_date = ''; } ?> <div align=right><FONT size='1'> <em><?php echo $current_module_strings['LBL_CREATED_ON'] . ' ' . $file_date; ?> </em>[<a href="javascript:;" onClick="changeView('<?php echo vtlib_purify($_REQUEST['display_view']); ?> ');"><?php echo $current_module_strings['LBL_REFRESH']; ?>
/** * Function to get todos list scheduled between specified dates * @param array $calendar - collection of objects and strings * @param string $start_date - date string * @param string $end_date - date string * @param string $info - string 'listcnt' or empty string. if 'listcnt' means it returns no. of todos and no. of pending todos in array format else it returns todos list in array format * return array $Entries - todolists in array format */ function getTodoList(&$calendar, $start_date, $end_date, $info = '') { global $log, $app_strings, $theme; $Entries = array(); $category = getParentTab(); global $adb, $current_user, $mod_strings, $cal_log, $list_max_entries_per_page; $cal_log->debug("Entering getTodoList() method..."); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; $count_qry = "SELECT count(*) as count FROM vtiger_activity\n\t\tINNER JOIN vtiger_crmentity\n\t\tON vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\tLEFT JOIN vtiger_cntactivityrel\n\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\tLEFT JOIN vtiger_groups\n\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\tLEFT JOIN vtiger_users\n\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n\t\tWHERE vtiger_crmentity.deleted = 0\n\t\tAND vtiger_activity.activitytype = 'Task'\n\t\tAND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id; $query = "SELECT vtiger_groups.groupname, vtiger_users.user_name, vtiger_crmentity.crmid, vtiger_cntactivityrel.contactid, \n\t\t\t\tvtiger_activity.* FROM vtiger_activity\n INNER JOIN vtiger_crmentity\n\t\t\t\t\tON vtiger_crmentity.crmid = vtiger_activity.activityid\n LEFT JOIN vtiger_cntactivityrel\n\t\t\t\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users\n\t\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n WHERE vtiger_crmentity.deleted = 0\n\t\t\t\t\tAND vtiger_activity.activitytype = 'Task'\n\t\t\t\t\tAND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id; $list_query = $query; // User Select Customization /*$only_for_user = calendarview_getSelectedUserId(); if($only_for_user != 'ALL') { $query .= " AND vtiger_crmentity.smownerid = " . $only_for_user; $count_qry .= " AND vtiger_crmentity.smownerid = " . $only_for_user; }*/ // END $params = $info_params = array($start_date, $end_date); if ($info != '') { //added to fix #4816 $groupids = explode(",", fetchUserGroupids($current_user->id)); if (count($groupids) > 0) { $com_q = " AND (vtiger_crmentity.smownerid = ?\n\t\t\t\t\tOR vtiger_groups.groupid in (" . generateQuestionMarks($groupids) . "))"; } else { $com_q = " AND vtiger_crmentity.smownerid = ?"; } //end $pending_query = $query . " AND (vtiger_activity.status != 'Completed')" . $com_q; $total_q = $query . "" . $com_q; array_push($info_params, $current_user->id); if (count($groupids) > 0) { array_push($info_params, $groupids); } if ($adb->dbType == "pgsql") { $pending_query = fixPostgresQuery($pending_query, $log, 0); $total_q = fixPostgresQuery($total_q, $log, 0); } $total_res = $adb->pquery($total_q, $info_params); $total = $adb->num_rows($total_res); $res = $adb->pquery($pending_query, $info_params); $pending_rows = $adb->num_rows($res); $cal_log->debug("Exiting getTodoList() method..."); return array('totaltodo' => $total, 'pendingtodo' => $pending_rows); } if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[9] == 3) { $sec_parameter = getListViewSecurityParameter('Calendar'); $query .= $sec_parameter; $list_query .= $sec_parameter; $count_qry .= $sec_parameter; } $group_cond = ''; $count_res = $adb->pquery($count_qry, $params); $total_rec_count = $adb->query_result($count_res, 0, 'count'); $group_cond .= " ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC"; if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') { $start = vtlib_purify($_REQUEST['start']); } else { $start = 1; } $navigation_array = getNavigationValues($start, $total_rec_count, $list_max_entries_per_page); $start_rec = $navigation_array['start']; $end_rec = $navigation_array['end_val']; if ($start_rec <= 1) { $start_rec = 0; } else { $start_rec = $start_rec - 1; } $query .= $group_cond . " limit {$start_rec},{$list_max_entries_per_page}"; $list_query .= $group_cond; if ($adb->dbType == "pgsql") { $query = fixPostgresQuery($query, $log, 0); $list_query = fixPostgresQuery($list_query, $log, 0); } $list_query = $adb->convert2Sql($list_query, $params); $_SESSION['Calendar_listquery'] = $list_query; $result = $adb->pquery($query, $params); $rows = $adb->num_rows($result); $c = 0; if ($start > 1) { $c = ($start - 1) * $list_max_entries_per_page; } for ($i = 0; $i < $rows; $i++) { $element = array(); $contact_name = ''; $element['no'] = $c + 1; $more_link = ""; $start_time = $adb->query_result($result, $i, "time_start"); $format = $calendar['calendar']->hour_format; $value = getaddEventPopupTime($start_time, $start_time, $format); $element['starttime'] = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt']; $date_start = $adb->query_result($result, $i, "date_start"); $due_date = $adb->query_result($result, $i, "due_date"); if ($calendar['view'] != 'day') { $element['startdate'] = getDisplayDate($date_start); } $element['duedate'] = getDisplayDate($due_date); $id = $adb->query_result($result, $i, "activityid"); $subject = $adb->query_result($result, $i, "subject"); //CHANGE : TO IMPROVE PERFORMANCE /*$contact_id = $adb->query_result($result,$i,"contactid"); if($contact_id!='') { $contact_name = getContactName($contact_id); }*/ $more_link = "<a href='index.php?action=DetailView&module=Calendar&record=" . $id . "&activity_mode=Task&viewtype=calendar&parenttab=" . $category . "' class='webMnu'>" . $subject . "</a>"; $element['tododetail'] = $more_link; /*if(getFieldVisibilityPermission('Calendar',$current_user->id,'parent_id') == '0') { $element['task_relatedto'] = getRelatedTo('Calendar',$result,$i); } if(getFieldVisibilityPermission('Calendar',$current_user->id,'contact_id') == '0') { $element['task_contact'] = "<a href=\"index.php?module=Contacts&action=DetailView&record=".$contact_id."\">".$contact_name."</a>"; }*/ if (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') { $taskstatus = $adb->query_result($result, $i, "status"); if (!$is_admin && $taskstatus != '') { $roleid = $current_user->roleid; $roleids = array(); $subrole = getRoleSubordinates($roleid); if (count($subrole) > 0) { $roleids = $subrole; } array_push($roleids, $roleid); //here we are checking wheather the table contains the sortorder column .If sortorder is present in the main picklist table, then the role2picklist will be applicable for this table... $sql = "select * from vtiger_taskstatus where taskstatus=?"; $res = $adb->pquery($sql, array(decode_html($taskstatus))); $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid'); if ($picklistvalueid != null) { $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")"; $res_val = $adb->pquery($pick_query, array($roleids)); $num_val = $adb->num_rows($res_val); } if ($num_val > 0) { $element['status'] = getTranslatedString(decode_html($taskstatus)); } else { $element['status'] = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>"; } } else { $element['status'] = getTranslatedString(decode_html($taskstatus)); } } if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") { $element['action'] = "<img onClick='getcalAction(this,\"taskcalAction\"," . $id . ",\"" . $calendar['view'] . "\",\"" . $calendar['calendar']->date_time->hour . "\",\"" . $calendar['calendar']->date_time->get_formatted_date() . "\",\"todo\");' src='" . vtiger_imageurl('cal_event.jpg', $theme) . "' border='0'>"; } $assignedto = $adb->query_result($result, $i, "user_name"); if (!empty($assignedto)) { $element['assignedto'] = $assignedto; } else { $element['assignedto'] = $adb->query_result($result, $i, "groupname"); } $c++; $Entries[] = $element; } $ret_arr[0] = $Entries; $ret_arr[1] = $navigation_array; $cal_log->debug("Exiting getTodoList() method..."); return $ret_arr; }
function GenerateReport($outputformat, $filterlist, $directOutput = false) { global $adb, $current_user, $php_max_execution_time; global $modules, $app_strings; global $mod_strings, $current_language; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $modules_selected = array(); $modules_selected[] = $this->primarymodule; if (!empty($this->secondarymodule)) { $sec_modules = split(":", $this->secondarymodule); for ($i = 0; $i < count($sec_modules); $i++) { $modules_selected[] = $sec_modules[$i]; } } // Update Currency Field list $currencyfieldres = $adb->pquery("SELECT tabid, fieldlabel, uitype from vtiger_field WHERE uitype in (71,72,10)", array()); if ($currencyfieldres) { foreach ($currencyfieldres as $currencyfieldrow) { $modprefixedlabel = getTabModuleName($currencyfieldrow['tabid']) . ' ' . $currencyfieldrow['fieldlabel']; $modprefixedlabel = str_replace(' ', '_', $modprefixedlabel); if ($currencyfieldrow['uitype'] != 10) { if (!in_array($modprefixedlabel, $this->convert_currency) && !in_array($modprefixedlabel, $this->append_currency_symbol_to_value)) { $this->convert_currency[] = $modprefixedlabel; } } else { if (!in_array($modprefixedlabel, $this->ui10_fields)) { $this->ui10_fields[] = $modprefixedlabel; } } } } if ($outputformat == "HTML") { $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist); $result = $adb->query($sSQL); $error_msg = $adb->database->ErrorMsg(); if (!$result && $error_msg != '') { // Performance Optimization: If direct output is requried if ($directOutput) { echo getTranslatedString('LBL_REPORT_GENERATION_FAILED', $currentModule) . "<br>" . $error_msg; $error_msg = false; } // END return $error_msg; } // Performance Optimization: If direct output is required if ($directOutput) { echo '<table cellpadding="5" cellspacing="0" align="center" class="rptTable"><tr>'; } // END if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result); $arrayHeaders = array(); for ($x = 0; $x < $y; $x++) { $fld = $adb->field_name($result, $x); if (in_array($this->getLstringforReportHeaders($fld->name), $arrayHeaders)) { $headerLabel = str_replace("_", " ", $fld->name); $arrayHeaders[] = $headerLabel; } else { $headerLabel = str_replace($modules, " ", $this->getLstringforReportHeaders($fld->name)); $headerLabel = str_replace("_", " ", $this->getLstringforReportHeaders($fld->name)); $arrayHeaders[] = $headerLabel; } /*STRING TRANSLATION starts */ $mod_name = split(' ', $headerLabel, 2); $module = ''; if (in_array($mod_name[0], $modules_selected)) { $module = getTranslatedString($mod_name[0], $mod_name[0]); } if (!empty($this->secondarymodule)) { if ($module != '') { $headerLabel_tmp = $module . " " . getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } else { if ($module != '') { $headerLabel_tmp = getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } if ($headerLabel == $headerLabel_tmp) { $headerLabel = getTranslatedString($headerLabel_tmp); } else { $headerLabel = $headerLabel_tmp; } /*STRING TRANSLATION ends */ $header .= "<td class='rptCellLabel'>" . $headerLabel . "</td>"; // Performance Optimization: If direct output is required if ($directOutput) { echo $header; $header = ''; } // END } // Performance Optimization: If direct output is required if ($directOutput) { echo '</tr><tr>'; } // END $noofrows = $adb->num_rows($result); $custom_field_values = $adb->fetch_array($result); $groupslist = $this->getGroupingList($this->reportid); $column_definitions = $adb->getFieldsDefinition($result); do { $arraylists = array(); if (count($groupslist) == 1) { $newvalue = $custom_field_values[0]; } elseif (count($groupslist) == 2) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; } elseif (count($groupslist) == 3) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; $tnewvalue = $custom_field_values[2]; } if ($newvalue == "") { $newvalue = "-"; } if ($snewvalue == "") { $snewvalue = "-"; } if ($tnewvalue == "") { $tnewvalue = "-"; } $valtemplate .= "<tr>"; // Performance Optimization if ($directOutput) { echo $valtemplate; $valtemplate = ''; } // END for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $fld_type = $column_definitions[$i]->type; if (in_array($fld->name, $this->convert_currency)) { if ($custom_field_values[$i] != '') { $fieldvalue = convertFromMasterCurrency($custom_field_values[$i], $current_user->conv_rate); } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } elseif (in_array($fld->name, $this->append_currency_symbol_to_value)) { $curid_value = explode("::", $custom_field_values[$i]); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); if ($custom_field_values[$i] != '') { $fieldvalue = $cur_sym_rate['symbol'] . " " . $currency_value; } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } elseif ($fld->name == "PurchaseOrder_Currency" || $fld->name == "SalesOrder_Currency" || $fld->name == "Invoice_Currency" || $fld->name == "Quotes_Currency") { if ($custom_field_values[$i] != '') { $fieldvalue = getCurrencyName($custom_field_values[$i]); } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } elseif (in_array($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $type = getSalesEntityType($custom_field_values[$i]); $tmp = getEntityName($type, $custom_field_values[$i]); foreach ($tmp as $key => $val) { $fieldvalue = $val; break; } } else { if ($custom_field_values[$i] != '') { $fieldvalue = getTranslatedString($custom_field_values[$i]); } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); //check for Roll based pick list $temp_val = $fld->name; if (is_array($picklistarray)) { if (array_key_exists($temp_val, $picklistarray)) { if (!in_array($custom_field_values[$i], $picklistarray[$fld->name]) && $custom_field_values[$i] != '') { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } } } if (is_array($picklistarray[1])) { if (array_key_exists($temp_val, $picklistarray[1])) { $temp = explode(",", str_ireplace(' |##| ', ',', $fieldvalue)); $temp_val = array(); foreach ($temp as $key => $val) { if (!in_array(trim($val), $picklistarray[1][$fld->name]) && trim($val) != '') { $temp_val[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $temp_val[] = $val; } } $fieldvalue = is_array($temp_val) ? implode(", ", $temp_val) : ''; } } if ($fieldvalue == "") { $fieldvalue = "-"; } else { if (stristr($fieldvalue, "|##|")) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } else { if ($fld_type == "date" || $fld_type == "datetime") { $fieldvalue = getDisplayDate($fieldvalue); } } } if ($lastvalue == $fieldvalue && $this->reporttype == "summary") { if ($this->reporttype == "summary") { $valtemplate .= "<td class='rptEmptyGrp'> </td>"; } else { $valtemplate .= "<td class='rptData'>" . $fieldvalue . "</td>"; } } else { if ($secondvalue === $fieldvalue && $this->reporttype == "summary") { if ($lastvalue === $newvalue) { $valtemplate .= "<td class='rptEmptyGrp'> </td>"; } else { $valtemplate .= "<td class='rptGrpHead'>" . $fieldvalue . "</td>"; } } else { if ($thirdvalue === $fieldvalue && $this->reporttype == "summary") { if ($secondvalue === $snewvalue) { $valtemplate .= "<td class='rptEmptyGrp'> </td>"; } else { $valtemplate .= "<td class='rptGrpHead'>" . $fieldvalue . "</td>"; } } else { if ($this->reporttype == "tabular") { $valtemplate .= "<td class='rptData'>" . $fieldvalue . "</td>"; } else { $valtemplate .= "<td class='rptGrpHead'>" . $fieldvalue . "</td>"; } } } } // Performance Optimization: If direct output is required if ($directOutput) { echo $valtemplate; $valtemplate = ''; } // END } $valtemplate .= "</tr>"; // Performance Optimization: If direct output is required if ($directOutput) { echo $valtemplate; $valtemplate = ''; } // END $lastvalue = $newvalue; $secondvalue = $snewvalue; $thirdvalue = $tnewvalue; $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); } while ($custom_field_values = $adb->fetch_array($result)); // Performance Optimization if ($directOutput) { echo "</tr></table>"; echo "<script type='text/javascript' id='__reportrun_directoutput_recordcount_script'>\n\t\t\t\t\t\tif(\$('_reportrun_total')) \$('_reportrun_total').innerHTML={$noofrows};</script>"; } else { $sHTML = '<table cellpadding="5" cellspacing="0" align="center" class="rptTable"> <tr>' . $header . '<!-- BEGIN values --> <tr>' . $valtemplate . '</tr> </table>'; } //<<<<<<<<construct HTML>>>>>>>>>>>> $return_data[] = $sHTML; $return_data[] = $noofrows; $return_data[] = $sSQL; return $return_data; } } elseif ($outputformat == "PDF") { $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist); $result = $adb->query($sSQL); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result); $noofrows = $adb->num_rows($result); $custom_field_values = $adb->fetch_array($result); $column_definitions = $adb->getFieldsDefinition($result); do { $arraylists = array(); for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); if (in_array($fld->name, $this->convert_currency)) { $fieldvalue = convertFromMasterCurrency($custom_field_values[$i], $current_user->conv_rate); } elseif (in_array($fld->name, $this->append_currency_symbol_to_value)) { $curid_value = explode("::", $custom_field_values[$i]); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); $fieldvalue = $cur_sym_rate['symbol'] . " " . $currency_value; } elseif ($fld->name == "PurchaseOrder_Currency" || $fld->name == "SalesOrder_Currency" || $fld->name == "Invoice_Currency" || $fld->name == "Quotes_Currency") { $fieldvalue = getCurrencyName($custom_field_values[$i]); } elseif (in_array($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $type = getSalesEntityType($custom_field_values[$i]); $tmp = getEntityName($type, $custom_field_values[$i]); foreach ($tmp as $key => $val) { $fieldvalue = $val; break; } } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } $append_cur = str_replace($fld->name, "", decode_html($this->getLstringforReportHeaders($fld->name))); $headerLabel = str_replace("_", " ", $fld->name); /*STRING TRANSLATION starts */ $mod_name = split(' ', $headerLabel, 2); $module = ''; if (in_array($mod_name[0], $modules_selected)) { $module = getTranslatedString($mod_name[0], $mod_name[0]); } if (!empty($this->secondarymodule)) { if ($module != '') { $headerLabel_tmp = $module . " " . getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } else { if ($module != '') { $headerLabel_tmp = getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } if ($headerLabel == $headerLabel_tmp) { $headerLabel = getTranslatedString($headerLabel_tmp); } else { $headerLabel = $headerLabel_tmp; } /*STRING TRANSLATION starts */ if (trim($append_cur) != "") { $headerLabel .= $append_cur; } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); // Check for role based pick list $temp_val = $fld->name; if (is_array($picklistarray)) { if (array_key_exists($temp_val, $picklistarray)) { if (!in_array($custom_field_values[$i], $picklistarray[$fld->name]) && $custom_field_values[$i] != '') { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } } } if (is_array($picklistarray[1])) { if (array_key_exists($temp_val, $picklistarray[1])) { $temp = explode(",", str_ireplace(' |##| ', ',', $fieldvalue)); $temp_val = array(); foreach ($temp as $key => $val) { if (!in_array(trim($val), $picklistarray[1][$fld->name]) && trim($val) != '') { $temp_val[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $temp_val[] = $val; } } $fieldvalue = is_array($temp_val) ? implode(", ", $temp_val) : ''; } } if ($fieldvalue == "") { $fieldvalue = "-"; } else { if (stristr($fieldvalue, "|##|")) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } else { if ($fld_type == "date" || $fld_type == "datetime") { $fieldvalue = getDisplayDate($fieldvalue); } } } if (array_key_exists($this->getLstringforReportHeaders($fld->name), $arraylists)) { $arraylists[$headerLabel] = $fieldvalue; } else { $arraylists[$headerLabel] = $fieldvalue; } } $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); } while ($custom_field_values = $adb->fetch_array($result)); return $arr_val; } } elseif ($outputformat == "TOTALHTML") { $escapedchars = array('_SUM', '_AVG', '_MIN', '_MAX'); $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist, "COLUMNSTOTOTAL"); if (isset($this->totallist)) { if ($sSQL != "") { $result = $adb->query($sSQL); $y = $adb->num_fields($result); $custom_field_values = $adb->fetch_array($result); $coltotalhtml .= "<table align='center' width='60%' cellpadding='3' cellspacing='0' border='0' class='rptTable'><tr><td class='rptCellLabel'>" . $mod_strings[Totals] . "</td><td class='rptCellLabel'>" . $mod_strings[SUM] . "</td><td class='rptCellLabel'>" . $mod_strings[AVG] . "</td><td class='rptCellLabel'>" . $mod_strings[MIN] . "</td><td class='rptCellLabel'>" . $mod_strings[MAX] . "</td></tr>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END foreach ($this->totallist as $key => $value) { $fieldlist = explode(":", $key); $mod_query = $adb->pquery("SELECT distinct(tabid) as tabid, uitype as uitype from vtiger_field where tablename = ? and columnname=?", array($fieldlist[1], $fieldlist[2])); if ($adb->num_rows($mod_query) > 0) { $module_name = getTabName($adb->query_result($mod_query, 0, 'tabid')); $fieldlabel = trim(str_replace($escapedchars, " ", $fieldlist[3])); $fieldlabel = str_replace("_", " ", $fieldlabel); if ($module_name) { $field = getTranslatedString($module_name) . " " . getTranslatedString($fieldlabel, $module_name); } else { $field = getTranslatedString($module_name) . " " . getTranslatedString($fieldlabel); } } $uitype_arr[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $adb->query_result($mod_query, 0, "uitype"); $totclmnflds[str_replace($escapedchars, " ", $module_name . "_" . $fieldlist[3])] = $field; } for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $keyhdr[$fld->name] = $custom_field_values[$i]; } foreach ($totclmnflds as $key => $value) { $coltotalhtml .= '<tr class="rptGrpHead" valign=top>'; $col_header = trim(str_replace($modules, " ", $value)); $fld_name_1 = $this->primarymodule . "_" . trim($value); $fld_name_2 = $this->secondarymodule . "_" . trim($value); if ($uitype_arr[$value] == 71 || in_array($fld_name_1, $this->convert_currency) || in_array($fld_name_1, $this->append_currency_symbol_to_value) || in_array($fld_name_2, $this->convert_currency) || in_array($fld_name_2, $this->append_currency_symbol_to_value)) { $col_header .= " (" . $app_strings['LBL_IN'] . " " . $current_user->currency_symbol . ")"; $convert_price = true; } else { $convert_price = false; } $coltotalhtml .= '<td class="rptData">' . $col_header . '</td>'; $value = trim($key); $arraykey = $value . '_SUM'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $arraykey = $value . '_AVG'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $arraykey = $value . '_MIN'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $arraykey = $value . '_MAX'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td class="rptTotal">' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td class="rptTotal"> </td>'; } $coltotalhtml .= '<tr>'; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END } $coltotalhtml .= "</table>"; // Performation Optimization: If Direct output is desired if ($directOutput) { echo $coltotalhtml; $coltotalhtml = ''; } // END } } return $coltotalhtml; } elseif ($outputformat == "PRINT") { $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist); $result = $adb->query($sSQL); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) { $picklistarray = $this->getAccessPickListValues(); } if ($result) { $y = $adb->num_fields($result); $arrayHeaders = array(); for ($x = 0; $x < $y; $x++) { $fld = $adb->field_name($result, $x); if (in_array($this->getLstringforReportHeaders($fld->name), $arrayHeaders)) { $headerLabel = str_replace("_", " ", $fld->name); $arrayHeaders[] = $headerLabel; } else { $headerLabel = str_replace($modules, " ", $this->getLstringforReportHeaders($fld->name)); $arrayHeaders[] = $headerLabel; } /*STRING TRANSLATION starts */ $mod_name = split(' ', $headerLabel, 2); $module = ''; if (in_array($mod_name[0], $modules_selected)) { $module = getTranslatedString($mod_name[0], $mod_name[0]); } if (!empty($this->secondarymodule)) { if ($module != '') { $headerLabel_tmp = $module . " " . getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } else { if ($module != '') { $headerLabel_tmp = getTranslatedString($mod_name[1], $mod_name[0]); } else { $headerLabel_tmp = getTranslatedString($mod_name[0] . " " . $mod_name[1]); } } if ($headerLabel == $headerLabel_tmp) { $headerLabel = getTranslatedString($headerLabel_tmp); } else { $headerLabel = $headerLabel_tmp; } /*STRING TRANSLATION ends */ $header .= "<th>" . $headerLabel . "</th>"; } $noofrows = $adb->num_rows($result); $custom_field_values = $adb->fetch_array($result); $groupslist = $this->getGroupingList($this->reportid); $column_definitions = $adb->getFieldsDefinition($result); do { $arraylists = array(); if (count($groupslist) == 1) { $newvalue = $custom_field_values[0]; } elseif (count($groupslist) == 2) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; } elseif (count($groupslist) == 3) { $newvalue = $custom_field_values[0]; $snewvalue = $custom_field_values[1]; $tnewvalue = $custom_field_values[2]; } if ($newvalue == "") { $newvalue = "-"; } if ($snewvalue == "") { $snewvalue = "-"; } if ($tnewvalue == "") { $tnewvalue = "-"; } $valtemplate .= "<tr>"; for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); if (in_array($fld->name, $this->convert_currency)) { $fieldvalue = convertFromMasterCurrency($custom_field_values[$i], $current_user->conv_rate); } elseif (in_array($fld->name, $this->append_currency_symbol_to_value)) { $curid_value = explode("::", $custom_field_values[$i]); $currency_id = $curid_value[0]; $currency_value = $curid_value[1]; $cur_sym_rate = getCurrencySymbolandCRate($currency_id); $fieldvalue = $cur_sym_rate['symbol'] . " " . $currency_value; } elseif ($fld->name == "PurchaseOrder_Currency" || $fld->name == "SalesOrder_Currency" || $fld->name == "Invoice_Currency" || $fld->name == "Quotes_Currency") { $fieldvalue = getCurrencyName($custom_field_values[$i]); } elseif (in_array($fld->name, $this->ui10_fields) && !empty($custom_field_values[$i])) { $type = getSalesEntityType($custom_field_values[$i]); $tmp = getEntityName($type, $custom_field_values[$i]); foreach ($tmp as $key => $val) { $fieldvalue = $val; break; } } else { $fieldvalue = getTranslatedString($custom_field_values[$i]); } $fieldvalue = str_replace("<", "<", $fieldvalue); $fieldvalue = str_replace(">", ">", $fieldvalue); //Check For Role based pick list $temp_val = $fld->name; if (is_array($picklistarray)) { if (array_key_exists($temp_val, $picklistarray)) { if (!in_array($custom_field_values[$i], $picklistarray[$fld->name]) && $custom_field_values[$i] != '') { $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE']; } } } if (is_array($picklistarray[1])) { if (array_key_exists($temp_val, $picklistarray[1])) { $temp = explode(",", str_ireplace(' |##| ', ',', $fieldvalue)); $temp_val = array(); foreach ($temp as $key => $val) { if (!in_array(trim($val), $picklistarray[1][$fld->name]) && trim($val) != '') { $temp_val[] = $app_strings['LBL_NOT_ACCESSIBLE']; } else { $temp_val[] = $val; } } $fieldvalue = is_array($temp_val) ? implode(", ", $temp_val) : ''; } } if ($fieldvalue == "") { $fieldvalue = "-"; } else { if (stristr($fieldvalue, "|##|")) { $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue); } else { if ($fld_type == "date" || $fld_type == "datetime") { $fieldvalue = getDisplayDate($fieldvalue); } } } if ($lastvalue == $fieldvalue && $this->reporttype == "summary") { if ($this->reporttype == "summary") { $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } else { if ($secondvalue == $fieldvalue && $this->reporttype == "summary") { if ($lastvalue == $newvalue) { $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } else { if ($thirdvalue == $fieldvalue && $this->reporttype == "summary") { if ($secondvalue == $snewvalue) { $valtemplate .= "<td style='border-top:1px dotted #FFFFFF;'> </td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } else { if ($this->reporttype == "tabular") { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } else { $valtemplate .= "<td>" . $fieldvalue . "</td>"; } } } } } $valtemplate .= "</tr>"; $lastvalue = $newvalue; $secondvalue = $snewvalue; $thirdvalue = $tnewvalue; $arr_val[] = $arraylists; set_time_limit($php_max_execution_time); } while ($custom_field_values = $adb->fetch_array($result)); $sHTML = '<tr>' . $header . '</tr>' . $valtemplate; $return_data[] = $sHTML; $return_data[] = $noofrows; return $return_data; } } elseif ($outputformat == "PRINT_TOTAL") { $escapedchars = array('_SUM', '_AVG', '_MIN', '_MAX'); $sSQL = $this->sGetSQLforReport($this->reportid, $filterlist, "COLUMNSTOTOTAL"); if (isset($this->totallist)) { if ($sSQL != "") { $result = $adb->query($sSQL); $y = $adb->num_fields($result); $custom_field_values = $adb->fetch_array($result); $coltotalhtml .= '<table width="100%" border="0" cellpadding="5" cellspacing="0" align="center" class="printReport" ><tr><th>' . $mod_strings[Totals] . '</th><th>' . $mod_strings[SUM] . '</th><th>' . $mod_strings[AVG] . '</th><th>' . $mod_strings[MIN] . '</th><th>' . $mod_strings[MAX] . '</th></tr>'; foreach ($this->totallist as $key => $value) { $fieldlist = explode(":", $key); $totclmnflds[str_replace($escapedchars, " ", $fieldlist[3])] = str_replace($escapedchars, " ", $fieldlist[3]); } for ($i = 0; $i < $y; $i++) { $fld = $adb->field_name($result, $i); $keyhdr[$fld->name] = $custom_field_values[$i]; } foreach ($totclmnflds as $key => $value) { $coltotalhtml .= '<tr valign=top>'; $col_header = getTranslatedString(trim(str_replace($modules, " ", $value))); $fld_name_1 = $this->primarymodule . "_" . trim($value); $fld_name_2 = $this->secondarymodule . "_" . trim($value); if (in_array($fld_name_1, $this->convert_currency) || in_array($fld_name_1, $this->append_currency_symbol_to_value) || in_array($fld_name_2, $this->convert_currency) || in_array($fld_name_2, $this->append_currency_symbol_to_value)) { $col_header .= " (" . $app_strings['LBL_IN'] . " " . $current_user->currency_symbol . ")"; $convert_price = true; } else { $convert_price = false; } $coltotalhtml .= '<td>' . $col_header . '</td>'; $arraykey = trim($value) . '_SUM'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td>' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td> </td>'; } $arraykey = trim($value) . '_AVG'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td>' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td> </td>'; } $arraykey = trim($value) . '_MIN'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td>' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td> </td>'; } $arraykey = trim($value) . '_MAX'; if (isset($keyhdr[$arraykey])) { if ($convert_price) { $conv_value = convertFromMasterCurrency($keyhdr[$arraykey], $current_user->conv_rate); } else { $conv_value = $keyhdr[$arraykey]; } $coltotalhtml .= '<td>' . $conv_value . '</td>'; } else { $coltotalhtml .= '<td> </td>'; } $coltotalhtml .= '<tr>'; } $coltotalhtml .= "</table>"; } } return $coltotalhtml; } }
function createpdffile($idnumber, $purpose = '', $path = '', $current_id = '') { require_once 'include/tcpdf/tcpdf.php'; require_once 'include/tcpdf/config/tcpdf_config.php'; require_once 'modules/SalesOrder/SalesOrder.php'; require_once 'include/database/PearDatabase.php'; require_once 'include/utils/InventoryUtils.php'; require_once 'include/utils/PDFutils.php'; require_once 'test/contact/bank.php'; global $FOOTER_PAGE, $default_font, $font_size_footer, $NUM_FACTURE_NAME, $pdf_strings, $SalesOrder_no, $footer_margin; global $org_name, $org_address, $org_city, $org_code, $org_country, $org_irs, $org_taxid, $org_phone, $org_fax, $org_website; global $VAR40_NAME, $VAR3_NAME, $VAR4_NAME, $ORG_POSITION, $VAR_PAGE, $VAR_OF; //bank information - content global $bank_name, $bank_street, $bank_city, $bank_zip, $bank_country, $bank_account, $bank_routing, $bank_iban, $bank_swift; //bank information - labels from language files global $ACCOUNT_NUMBER, $ROUTING_NUMBER, $SWIFT_NUMBER, $IBAN_NUMBER; global $columns, $logoradio, $logo_name, $footerradio, $pageradio; global $adb, $app_strings, $focus, $current_user; $module = 'SalesOrder'; //get bank information $bank_name = $bank_array['bank_name']; $bank_street = $bank_array['bank_street']; $bank_city = $bank_array['bank_city']; $bank_zip = $bank_array['bank_zip']; $bank_country = $bank_array['bank_country']; $bank_account = $bank_array['bank_account']; $bank_routing = $bank_array['bank_routing']; $bank_iban = $bank_array['bank_iban']; $bank_swift = $bank_array['bank_swift']; //get tax information $org_taxid = $tax_array['org_taxid']; $org_irs = $tax_array['org_irs']; //get the stored configuration values $pdf_config_details = getAllPDFDetails('SalesOrder'); //set font $default_font = getTCPDFFontsname($pdf_config_details[fontid]); if ($default_font == '') { $default_font = 'freesans'; } $font_size_header = $pdf_config_details[fontsizeheader]; $font_size_address = $pdf_config_details[fontsizeaddress]; $font_size_body = $pdf_config_details[fontsizebody]; $font_size_footer = $pdf_config_details[fontsizefooter]; //select comma or dot as number format //European Format $decimal_precision = 2; $decimals_separator = ','; $thousands_separator = '.'; //US Format //$decimal_precision = 2; //$decimals_separator = '.'; //$thousands_separator = ','; //get users data //select language file if (file_exists("modules/SalesOrder/language/" . $pdf_config_details[pdflang] . ".lang.pdf.php")) { include "modules/SalesOrder/language/" . $pdf_config_details[pdflang] . ".lang.pdf.php"; $language = strtoupper(substr($pdf_config_details[pdflang], -2, 2)); } else { include "modules/SalesOrder/language/en_us.lang.pdf.php"; $language = "EN"; } //internal number $id = $idnumber; //retreiving the salesorder info $focus = new SalesOrder(); $focus->retrieve_entity_info($_REQUEST['record'], "SalesOrder"); $account_name = decode_html(getAccountName($focus->column_fields['account_id'])); $SalesOrder_no = $focus->column_fields['salesorder_no']; $sql = "select vtiger_currency_info.currency_symbol from vtiger_currency_info where vtiger_currency_info.id= " . $focus->column_fields['currency_id']; $currency_symbol = $adb->query_result($adb->query($sql), 0, 'currency_symbol'); //get the SO date set $date_to_display_array = array(str_replace("-", ".", getDisplayDate(date("Y-m-d")))); $date_created = getDisplayDate($focus->column_fields['createdtime']); $date_array = explode(" ", $date_created); $date_to_display_array[1] = str_replace("-", ".", $date_array[0]); $date_modified = getDisplayDate($focus->column_fields['modifiedtime']); $date_array = explode(" ", $date_modified); $date_to_display_array[2] = str_replace("-", ".", $date_array[0]); $date_to_display = $date_to_display_array[$pdf_config_details['dateused']]; //number of lines after headline $space_headline = $pdf_config_details['space_headline']; //display logo? $logoradio = $pdf_config_details['logoradio']; //display customer sign? $clientid = $pdf_config_details['clientid']; //display summary? $summaryradio = $pdf_config_details['summaryradio']; //display footer? $footerradio = $pdf_config_details['footerradio']; //display footer page number? $pageradio = $pdf_config_details['pageradio']; // get company information from settings $add_query = "select * from vtiger_organizationdetails"; $result = $adb->query($add_query); $num_rows = $adb->num_rows($result); if ($num_rows > 0) { $org_name = $adb->query_result($result, 0, "organizationname"); $org_address = $adb->query_result($result, 0, "address"); $org_city = $adb->query_result($result, 0, "city"); $org_state = $adb->query_result($result, 0, "state"); $org_country = $adb->query_result($result, 0, "country"); $org_code = $adb->query_result($result, 0, "code"); $org_phone = $adb->query_result($result, 0, "phone"); $org_fax = $adb->query_result($result, 0, "fax"); $org_website = $adb->query_result($result, 0, "website"); $logo_name = $adb->query_result($result, 0, "logoname"); } // get owner information $recordOwnerArr = getRecordOwnerId($_REQUEST['record']); foreach ($recordOwnerArr as $type => $id) { $ownertype = $type; $ownerid = $id; } if ($ownertype == 'Users') { // get owner information for user $sql = "SELECT * FROM vtiger_users,vtiger_crmentity WHERE vtiger_users.id = vtiger_crmentity.smownerid AND vtiger_crmentity.crmid = '" . $_REQUEST['record'] . "'"; $result = $adb->query($sql); $owner_lastname = $adb->query_result($result, 0, 'last_name'); $owner_firstname = $adb->query_result($result, 0, 'first_name'); $owner_id = $adb->query_result($result, 0, 'smownerid'); $owner_phone = $adb->query_result($result, 0, 'phone_work'); $owner_title = decode_html(trim($adb->query_result($result, 0, 'title'))); } else { // get owner information for Groups $sql = "SELECT * FROM vtiger_groups,vtiger_crmentity WHERE vtiger_groups.groupid = vtiger_crmentity.smownerid AND vtiger_crmentity.crmid = '" . $_REQUEST['record'] . "'"; $result = $adb->query($sql); $owner_lastname = ''; $owner_firstname = $adb->query_result($result, 0, 'groupname'); $owner_id = $adb->query_result($result, 0, 'smownerid'); $owner_phone = $org_phone; $owner_title = ''; } //display owner? $owner = $pdf_config_details['owner']; //display owner phone#? $ownerphone = $pdf_config_details['ownerphone']; //to display at product description based on tax type $gproddetailarray = array($pdf_config_details[gprodname], $pdf_config_details[gproddes], $pdf_config_details[gprodcom]); $gproddetails = 0; foreach ($gproddetailarray as $key => $value) { if ($value == 'true') { if ($key == 0) { $gproddetails = $gproddetails + 1; } else { $gproddetails = $gproddetails + $key * 2; } } } $iproddetails = 0; $iproddetailarray = array($pdf_config_details[iprodname], $pdf_config_details[iproddes], $pdf_config_details[iprodcom]); foreach ($iproddetailarray as $key => $value) { if ($value == 'true') { if ($key == 0) { $iproddetails = $iproddetails + 1; } else { $iproddetails = $iproddetails + $key * 2; } } } // SO Requisition Nummer $requisition_no = $focus->column_fields['vtiger_purchaseorder']; // CustomerMark $customermark = $focus->column_fields['customerno']; if ($focus->column_fields['hdnTaxType'] == 'individual') { $product_taxes = 'true'; } else { $product_taxes = 'false'; } // **************** BEGIN POPULATE DATA ******************** $account_id = $focus->column_fields[account_id]; $so_id = $_REQUEST['record']; if ($focus->column_fields["quote_id"] != '') { $quote_name = getQuoteName($focus->column_fields["quote_id"]); } else { $quote_name = ''; } $po_name = $focus->column_fields["vtiger_purchaseorder"]; $subject = $focus->column_fields["subject"]; $delivery_date = $focus->column_fields["duedate"]; $delivery_date = str_replace("-", ".", getDisplayDate($delivery_date)); $bill_street = decode_html($focus->column_fields["bill_street"]); $bill_city = decode_html($focus->column_fields["bill_city"]); $bill_state = decode_html($focus->column_fields["bill_state"]); $bill_code = decode_html($focus->column_fields["bill_code"]); $bill_country = decode_html($focus->column_fields["bill_country"]); //format contact name $contact_name = decode_html(getContactforPDF($focus->column_fields["contact_id"])); //get department of contact or account, contact wins $contact_department = ''; //get contact department if (trim($focus->column_fields["contact_id"]) != '') { $sql = "select * from vtiger_contactdetails where contactid=" . $focus->column_fields["contact_id"]; $result = $adb->query($sql); $contact_department = decode_html(trim($adb->query_result($result, 0, "department"))); $contact_firstname = decode_html(trim($adb->query_result($result, 0, "firstname"))); $contact_lastname = decode_html(trim($adb->query_result($result, 0, "lastname"))); $contact_salutation = decode_html(trim($adb->query_result($result, 0, "salutation"))); } //get account department if ($contact_department == '') { $sql = "select * from vtiger_account where accountid=" . $account_id; $result = $adb->query($sql); $contact_department = decode_html(trim($adb->query_result($result, 0, "tickersymbol"))); } $ship_street = $focus->column_fields["ship_street"]; $ship_city = $focus->column_fields["ship_city"]; $ship_state = $focus->column_fields["ship_state"]; $ship_code = $focus->column_fields["ship_code"]; $ship_country = $focus->column_fields["ship_country"]; // condition field for last page $conditions = decode_html($focus->column_fields["terms_conditions"]); // description field for first page $description = decode_html($focus->column_fields["description"]); // ************************ BEGIN POPULATE DATA *************************** //get the Associated Products for this Sales Order $focus->id = $focus->column_fields["record_id"]; $associated_products = getAssociatedProducts("SalesOrder", $focus); $num_products = count($associated_products); //This $final_details array will contain the final total, discount, Group Tax, S&H charge, S&H taxes and adjustment $final_details = $associated_products[1]['final_details']; //getting the Net Total $price_subtotal = $final_details["hdnSubTotal"]; $price_subtotal_formated = number_format($price_subtotal, $decimal_precision, $decimals_separator, $thousands_separator); //Final discount amount/percentage $discount_amount = $final_details["discount_amount_final"]; $discount_percent = $final_details["discount_percentage_final"]; if ($discount_amount != "") { $price_discount = $discount_amount; $price_discount_formated = number_format($price_discount, $decimal_precision, $decimals_separator, $thousands_separator); } else { if ($discount_percent != "") { //This will be displayed near Discount label $final_price_discount_percent = "(" . number_format($discount_percent, $decimal_precision, $decimals_separator, $thousands_separator) . " %)"; $price_discount = $discount_percent * $final_details["hdnSubTotal"] / 100; $price_discount_formated = number_format($price_discount, $decimal_precision, $decimals_separator, $thousands_separator); } else { $price_discount = "0.00"; } } //Adjustment $price_adjustment = $final_details["adjustment"]; $price_adjustment_formated = number_format($price_adjustment, $decimal_precision, $decimals_separator, $thousands_separator); //Grand Total $price_total = $final_details["grandTotal"]; $price_total_formated = number_format($price_total, $decimal_precision, $decimals_separator, $thousands_separator); //To calculate the group tax amount if ($final_details['taxtype'] == 'group') { $group_tax_total = $final_details['tax_totalamount']; $price_salestax = $group_tax_total; $price_salestax_formated = number_format($price_salestax, $decimal_precision, $decimals_separator, $thousands_separator); $group_total_tax_percent = '0.00'; $group_tax_details = $final_details['taxes']; for ($i = 0; $i < count($group_tax_details); $i++) { $group_total_tax_percent = $group_total_tax_percent + $group_tax_details[$i]['percentage']; } } //S&H amount $sh_amount = $final_details['shipping_handling_charge']; $price_shipping_formated = number_format($sh_amount, $decimal_precision, $decimals_separator, $thousands_separator); //S&H taxes $sh_tax_details = $final_details['sh_taxes']; $sh_tax_percent = '0.00'; for ($i = 0; $i < count($sh_tax_details); $i++) { $sh_tax_percent = $sh_tax_percent + $sh_tax_details[$i]['percentage']; } $sh_tax_amount = $final_details['shtax_totalamount']; $price_shipping_tax = number_format($sh_tax_amount, $decimal_precision, $decimals_separator, $thousands_separator); //to calculate the individuel tax amounts included we should get all available taxes and then retrieve the corresponding tax values $tax_details = getAllTaxes('available'); $numer_of_tax_types = count($tax_details); for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) { $taxtype_listings[taxname . $tax_count] = $tax_details[$tax_count]['taxname']; $taxtype_listings[percentage . $tax_count] = $tax_details[$tax_count]['percentage']; $taxtype_listings[value . $tax_count] = '0'; } //This is to get all prodcut details as row basis for ($i = 1, $j = $i - 1; $i <= $num_products; $i++, $j++) { $product_code[$i] = $associated_products[$i]['hdnProductcode' . $i]; $product_name[$i] = decode_html($associated_products[$i]['productName' . $i]); $prod_description[$i] = decode_html($associated_products[$i]['productDescription' . $i]); $qty[$i] = $associated_products[$i]['qty' . $i]; $qty_formated[$i] = number_format($associated_products[$i]['qty' . $i], $decimal_precision, $decimals_separator, $thousands_separator); $comment[$i] = decode_html($associated_products[$i]['comment' . $i]); $unit_price[$i] = number_format($associated_products[$i]['unitPrice' . $i], $decimal_precision, $decimals_separator, $thousands_separator); $list_price[$i] = number_format($associated_products[$i]['listPrice' . $i], $decimal_precision, $decimals_separator, $thousands_separator); $list_pricet[$i] = $associated_products[$i]['listPrice' . $i]; $discount_total[$i] = $associated_products[$i]['discountTotal' . $i]; $discount_totalformated[$i] = number_format($associated_products[$i]['discountTotal' . $i], $decimal_precision, $decimals_separator, $thousands_separator); //added by crm-now $usageunit[$i] = $associated_products[$i]['usageunit' . $i]; //look whether the entry already exists, if the translated string is available then the translated string other wise original string will be returned $usageunit[$i] = getTranslatedString($usageunit[$i], 'Products'); $taxable_total = $qty[$i] * $list_pricet[$i] - $discount_total[$i]; $producttotal = $taxable_total; $total_taxes = '0.00'; if ($focus->column_fields["hdnTaxType"] == "individual") { $total_tax_percent = '0.00'; //This loop is to get all tax percentage and then calculate the total of all taxes for ($tax_count = 0; $tax_count < count($associated_products[$i]['taxes']); $tax_count++) { $tax_percent = $associated_products[$i]['taxes'][$tax_count]['percentage']; $total_tax_percent = $total_tax_percent + $tax_percent; $tax_amount = $taxable_total * $tax_percent / 100; //calculate the tax amount for any available tax percentage $detected_tax = substr(array_search($total_tax_percent, $taxtype_listings), -1); $taxtype_listings[value . $detected_tax] = $taxtype_listings[value . $detected_tax] + $tax_amount; $total_taxes = $total_taxes + $tax_amount; } $producttotal = $taxable_total + $total_taxes; $product_line[$j][$pdf_strings['Tax']] = " ({$total_tax_percent} %) " . number_format($total_taxes, $decimal_precision, $decimals_separator, $thousands_separator); // combine product name, description and comment to one field based on settings } // combine product name, description and comment to one field based on settings if ($focus->column_fields["hdnTaxType"] == "individual") { $product_selection = $iproddetails; } else { $product_selection = $gproddetails; } switch ($product_selection) { case 1: $product_name_long[$i] = $product_name[$i]; break; case 2: $product_name_long[$i] = $prod_description[$i]; break; case 3: $product_name_long[$i] = $product_name[$i] . "\n" . $prod_description[$i]; break; case 4: $product_name_long[$i] = $comment[$i]; break; case 5: $product_name_long[$i] = $product_name[$i] . "\n" . $comment[$i]; break; case 6: if ($prod_description[$i] != '') { $product_name_long[$i] = $prod_description[$i] . "\n" . $comment[$i]; } else { $product_name_long[$i] = $comment[$i]; } break; case 7: if ($prod_description[$i] != '') { $product_name_long[$i] = $product_name[$i] . "\n" . $prod_description[$i] . "\n" . $comment[$i]; } else { $product_name_long[$i] = $product_name[$i] . "\n" . $comment[$i]; } break; default: if ($prod_description[$i] != '') { $product_name_long[$i] = $product_name[$i] . "\n" . $prod_description[$i] . "\n" . $comment[$i]; } else { $product_name_long[$i] = $product_name[$i] . "\n" . $comment[$i]; } break; } $prod_total[$i] = number_format($producttotal, $decimal_precision, $decimals_separator, $thousands_separator); $product_line[$j][$pdf_strings['Position']] = $j + 1; $product_line[$j][$pdf_strings['OrderCode']] = $product_code[$i]; $product_line[$j][$pdf_strings['Description']] = $product_name_long[$i]; $product_line[$j][$pdf_strings['Qty']] = $qty_formated[$i]; $product_line[$j][$pdf_strings['Unit']] = $usageunit[$i]; $product_line[$j][$pdf_strings['UnitPrice']] = $list_price[$i]; $product_line[$j][$pdf_strings['Discount']] = $discount_totalformated[$i]; $product_line[$j][$pdf_strings['LineTotal']] = $prod_total[$i]; } //Population of current date $addyear = strtotime("+0 year"); $dat_fmt = $current_user->date_format == '' ? 'dd-mm-yyyy' : $current_user->date_format; $date_issued = $dat_fmt == 'dd-mm-yyyy' ? date('d-m-Y', $addyear) : ($dat_fmt == 'mm-dd-yyyy' ? date('m-d-Y', $addyear) : ($dat_fmt == 'yyyy-mm-dd' ? date('Y-m-d', $addyear) : '')); // ************************ END POPULATE DATA *************************** //************************BEGIN PDF FORMATING************************** // Extend the TCPDF class to create custom Header and Footer class MYPDF extends TCPDF { //modifiy tcpdf class footer public function Footer() { //To make the function Footer() work properly $this->AliasNbPages(); if (!isset($this->original_lMargin)) { $this->original_lMargin = $this->lMargin; } if (!isset($this->original_rMargin)) { $this->original_rMargin = $this->rMargin; } include "modules/SalesOrder/pdf_templates/footer.php"; } } $page_num = '1'; // create new PDF document //$pdf = new PDF( 'P', 'mm', 'A4' ); $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); // set font $pdf->SetFont($default_font, " ", $default_font_size); $pdf->setPrintHeader(0); //header switched off permanently // auto break on //$pdf->SetAutoPageBreak(true); // set footer fonts //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set pdf information $pdf->SetTitle($pdf_strings['FACTURE'] . ": " . $account_name); $pdf->SetAuthor($owner_firstname . " " . $owner_lastname . ", " . $org_name); $pdf->SetSubject($account_name); $pdf->SetCreator('PDF Creator from www.crm-now.com'); //list product names as keywords $productlisting = implode(", ", $product_name); $pdf->SetKeywords($productlisting); //Disable automatic page break $pdf->SetAutoPageBreak(true, PDF_MARGIN_FOOTER); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); //initialize document $pdf->AliasNbPages(); //in reference to body.php -> if a new page must be added if the space available for summary is too small $new_page_started = false; $pdf->AddPage(); $pdf->setImageScale(1.5); //$pdf->SetY(PDF_MARGIN_HEADER); include "modules/SalesOrder/pdf_templates/header.php"; $pdf->SetFont($default_font, " ", $font_size_body); include "modules/SalesOrder/pdf_templates/body.php"; // issue pdf if ($purpose == 'print') { $pdf->Output($pdf_strings['FACTURE'] . '_' . $date_issued . '.pdf', 'D'); } elseif ($purpose == 'send') { // send pdf with mail switch ($language) { case "EN": $pdf->Output('storage/SalesOrder_' . $_REQUEST['record'] . '.pdf', 'F'); //added file name to make it work in IE, also forces the download giving the user the option to save break; case "DE": $pdf->Output('storage/Bestellung_' . $_REQUEST['record'] . '.pdf', 'F'); //added file name to make it work in IE, also forces the download giving the user the option to save break; } return; } exit; }
function UpdateClndr($username, $session, $clndrdtls) { if (!validateSession($username, $session)) { return null; } global $current_user; global $adb, $log; require_once 'modules/Users/Users.php'; require_once 'modules/Calendar/Activity.php'; $seed_user = new Users(); $user_id = $seed_user->retrieve_user_id($username); $current_user = $seed_user; $current_user->retrieve_entity_info($user_id, "Users"); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) { $sql1 = "select fieldname,columnname from vtiger_field where tabid=16 and vtiger_field.presence in (0,2)"; $params1 = array(); } else { $profileList = getCurrentUserProfileList(); $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=16 and vtiger_field.displaytype in (1,2,4,3) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_field.presence in (0,2)"; $params1 = array(); if (count($profileList) > 0) { $sql1 .= " and vtiger_profile2field.profileid in (" . generateQuestionMarks($profileList) . ")"; array_push($params1, $profileList); } } $result1 = $adb->pquery($sql1, $params1); for ($i = 0; $i < $adb->num_rows($result1); $i++) { $permitted_lists[] = $adb->query_result($result1, $i, 'fieldname'); } $clndr = new Activity(); foreach ($clndrdtls as $clndrow) { if (isset($clndrow)) { $astartdtm = explode(" ", $clndrow["startdate"]); $aduedtm = explode(" ", $clndrow["duedate"]); $atimestart = explode(":", trim($astartdtm[1])); $atimedue = explode(":", trim($aduedtm[1])); $stimestart = $atimestart[0] . ":" . $atimestart[1]; $stimeend = $atimedue[0] . ":" . $atimedue[1]; /*if( $diff=@get_time_difference($stimestart, $stimeend) ) { $stimeduehr = sprintf('%02d',$diff['hours']); $stimeduemin = sprintf('%02d',$diff['minutes']); }*/ $clndr->retrieve_entity_info($clndrow["id"], "Calendar"); $clndr->column_fields[subject] = in_array('subject', $permitted_lists) ? $clndrow["subject"] : ""; $clndr->column_fields[date_start] = in_array('date_start', $permitted_lists) ? getDisplayDate(trim($astartdtm[0])) : ""; $clndr->column_fields[due_date] = in_array('due_date', $permitted_lists) ? getDisplayDate(trim($aduedtm[0])) : ""; $clndr->column_fields[time_start] = in_array('time_start', $permitted_lists) ? $stimestart : ""; $clndr->column_fields[time_end] = in_array('time_end', $permitted_lists) ? $stimeend : ""; //$clndr->column_fields[duration_hours]= in_array('duration_hours',$permitted_lists) ? $stimeduehr : ""; //$clndr->column_fields[duration_minutes]= in_array('duration_minutes',$permitted_lists) ? $stimeduemin : ""; $clndr->column_fields[location] = in_array('location', $permitted_lists) ? $clndrow["location"] : ""; $clndr->column_fields[description] = in_array('description', $permitted_lists) ? $clndrow["description"] : ""; $clndr->column_fields[activitytype] = "Meeting"; $clndr->column_fields[assigned_user_id] = in_array('assigned_user_id', $permitted_lists) ? $user_id : ""; $clndr->id = $clndrow["id"]; $clndr->mode = "edit"; $clndr->save("Calendar"); } } return $clndr->id; }
/** to get the standard filter criteria scripts * @returns $jsStr : Type String * This function will return the script to set the start data and end date * for the standard selection criteria */ function getCriteriaJS() { $today = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $tomorrow = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); $yesterday = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))); $currentmonth0 = date("Y-m-d", mktime(0, 0, 0, date("m"), "01", date("Y"))); $currentmonth1 = date("Y-m-t"); $lastmonth0 = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, "01", date("Y"))); $lastmonth1 = date("Y-m-t", strtotime("-1 Month")); $nextmonth0 = date("Y-m-d", mktime(0, 0, 0, date("m") + 1, "01", date("Y"))); $nextmonth1 = date("Y-m-t", strtotime("+1 Month")); $lastweek0 = date("Y-m-d", strtotime("-2 week Sunday")); $lastweek1 = date("Y-m-d", strtotime("-1 week Saturday")); $thisweek0 = date("Y-m-d", strtotime("-1 week Sunday")); $thisweek1 = date("Y-m-d", strtotime("this Saturday")); $nextweek0 = date("Y-m-d", strtotime("this Sunday")); $nextweek1 = date("Y-m-d", strtotime("+1 week Saturday")); $next7days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 6, date("Y"))); $next30days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 29, date("Y"))); $next60days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 59, date("Y"))); $next90days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 89, date("Y"))); $next120days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + 119, date("Y"))); $last7days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 6, date("Y"))); $last30days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 29, date("Y"))); $last60days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 59, date("Y"))); $last90days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 89, date("Y"))); $last120days = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 119, date("Y"))); $currentFY0 = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y"))); $currentFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y"))); $lastFY0 = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y") - 1)); $lastFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y") - 1)); $nextFY0 = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y") + 1)); $nextFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y") + 1)); if (date("m") <= 3) { $cFq = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "03", "31", date("Y"))); $nFq = date("Y-m-d", mktime(0, 0, 0, "04", "01", date("Y"))); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "06", "30", date("Y"))); $pFq = date("Y-m-d", mktime(0, 0, 0, "10", "01", date("Y") - 1)); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "12", "31", date("Y") - 1)); } else { if (date("m") > 3 and date("m") <= 6) { $pFq = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y"))); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "03", "31", date("Y"))); $cFq = date("Y-m-d", mktime(0, 0, 0, "04", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "06", "30", date("Y"))); $nFq = date("Y-m-d", mktime(0, 0, 0, "07", "01", date("Y"))); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "09", "30", date("Y"))); } else { if (date("m") > 6 and date("m") <= 9) { $nFq = date("Y-m-d", mktime(0, 0, 0, "10", "01", date("Y"))); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "12", "31", date("Y"))); $pFq = date("Y-m-d", mktime(0, 0, 0, "04", "01", date("Y"))); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "06", "30", date("Y"))); $cFq = date("Y-m-d", mktime(0, 0, 0, "07", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "09", "30", date("Y"))); } else { if (date("m") > 9 and date("m") <= 12) { $nFq = date("Y-m-d", mktime(0, 0, 0, "01", "01", date("Y") + 1)); $nFq1 = date("Y-m-d", mktime(0, 0, 0, "03", "31", date("Y") + 1)); $pFq = date("Y-m-d", mktime(0, 0, 0, "07", "01", date("Y"))); $pFq1 = date("Y-m-d", mktime(0, 0, 0, "09", "30", date("Y"))); $cFq = date("Y-m-d", mktime(0, 0, 0, "10", "01", date("Y"))); $cFq1 = date("Y-m-d", mktime(0, 0, 0, "12", "31", date("Y"))); } } } } $sjsStr = '<script language="JavaScript" type="text/javaScript"> function showDateRange( type ) { if (type!="custom") { document.CustomView.startdate.readOnly=true document.CustomView.enddate.readOnly=true getObj("jscal_trigger_date_start").style.visibility="hidden" getObj("jscal_trigger_date_end").style.visibility="hidden" } else { document.CustomView.startdate.readOnly=false document.CustomView.enddate.readOnly=false getObj("jscal_trigger_date_start").style.visibility="visible" getObj("jscal_trigger_date_end").style.visibility="visible" } if( type == "today" ) { document.CustomView.startdate.value = "' . getDisplayDate($today) . '"; document.CustomView.enddate.value = "' . getDisplayDate($today) . '"; } else if( type == "yesterday" ) { document.CustomView.startdate.value = "' . getDisplayDate($yesterday) . '"; document.CustomView.enddate.value = "' . getDisplayDate($yesterday) . '"; } else if( type == "tomorrow" ) { document.CustomView.startdate.value = "' . getDisplayDate($tomorrow) . '"; document.CustomView.enddate.value = "' . getDisplayDate($tomorrow) . '"; } else if( type == "thisweek" ) { document.CustomView.startdate.value = "' . getDisplayDate($thisweek0) . '"; document.CustomView.enddate.value = "' . getDisplayDate($thisweek1) . '"; } else if( type == "lastweek" ) { document.CustomView.startdate.value = "' . getDisplayDate($lastweek0) . '"; document.CustomView.enddate.value = "' . getDisplayDate($lastweek1) . '"; } else if( type == "nextweek" ) { document.CustomView.startdate.value = "' . getDisplayDate($nextweek0) . '"; document.CustomView.enddate.value = "' . getDisplayDate($nextweek1) . '"; } else if( type == "thismonth" ) { document.CustomView.startdate.value = "' . getDisplayDate($currentmonth0) . '"; document.CustomView.enddate.value = "' . getDisplayDate($currentmonth1) . '"; } else if( type == "lastmonth" ) { document.CustomView.startdate.value = "' . getDisplayDate($lastmonth0) . '"; document.CustomView.enddate.value = "' . getDisplayDate($lastmonth1) . '"; } else if( type == "nextmonth" ) { document.CustomView.startdate.value = "' . getDisplayDate($nextmonth0) . '"; document.CustomView.enddate.value = "' . getDisplayDate($nextmonth1) . '"; } else if( type == "next7days" ) { document.CustomView.startdate.value = "' . getDisplayDate($today) . '"; document.CustomView.enddate.value = "' . getDisplayDate($next7days) . '"; } else if( type == "next30days" ) { document.CustomView.startdate.value = "' . getDisplayDate($today) . '"; document.CustomView.enddate.value = "' . getDisplayDate($next30days) . '"; } else if( type == "next60days" ) { document.CustomView.startdate.value = "' . getDisplayDate($today) . '"; document.CustomView.enddate.value = "' . getDisplayDate($next60days) . '"; } else if( type == "next90days" ) { document.CustomView.startdate.value = "' . getDisplayDate($today) . '"; document.CustomView.enddate.value = "' . getDisplayDate($next90days) . '"; } else if( type == "next120days" ) { document.CustomView.startdate.value = "' . getDisplayDate($today) . '"; document.CustomView.enddate.value = "' . getDisplayDate($next120days) . '"; } else if( type == "last7days" ) { document.CustomView.startdate.value = "' . getDisplayDate($last7days) . '"; document.CustomView.enddate.value = "' . getDisplayDate($today) . '"; } else if( type == "last30days" ) { document.CustomView.startdate.value = "' . getDisplayDate($last30days) . '"; document.CustomView.enddate.value = "' . getDisplayDate($today) . '"; } else if( type == "last60days" ) { document.CustomView.startdate.value = "' . getDisplayDate($last60days) . '"; document.CustomView.enddate.value = "' . getDisplayDate($today) . '"; } else if( type == "last90days" ) { document.CustomView.startdate.value = "' . getDisplayDate($last90days) . '"; document.CustomView.enddate.value = "' . getDisplayDate($today) . '"; } else if( type == "last120days" ) { document.CustomView.startdate.value = "' . getDisplayDate($last120days) . '"; document.CustomView.enddate.value = "' . getDisplayDate($today) . '"; } else if( type == "thisfy" ) { document.CustomView.startdate.value = "' . getDisplayDate($currentFY0) . '"; document.CustomView.enddate.value = "' . getDisplayDate($currentFY1) . '"; } else if( type == "prevfy" ) { document.CustomView.startdate.value = "' . getDisplayDate($lastFY0) . '"; document.CustomView.enddate.value = "' . getDisplayDate($lastFY1) . '"; } else if( type == "nextfy" ) { document.CustomView.startdate.value = "' . getDisplayDate($nextFY0) . '"; document.CustomView.enddate.value = "' . getDisplayDate($nextFY1) . '"; } else if( type == "nextfq" ) { document.CustomView.startdate.value = "' . getDisplayDate($nFq) . '"; document.CustomView.enddate.value = "' . getDisplayDate($nFq1) . '"; } else if( type == "prevfq" ) { document.CustomView.startdate.value = "' . getDisplayDate($pFq) . '"; document.CustomView.enddate.value = "' . getDisplayDate($pFq1) . '"; } else if( type == "thisfq" ) { document.CustomView.startdate.value = "' . getDisplayDate($cFq) . '"; document.CustomView.enddate.value = "' . getDisplayDate($cFq1) . '"; } else { document.CustomView.startdate.value = ""; document.CustomView.enddate.value = ""; } } </script>'; return $sjsStr; }
function sendOrderEmail($order_id, $manuallysend = 0) { $mainframe = JFactory::getApplication(); $lang = JSFactory::getLang(); $jshopConfig = JSFactory::getConfig(); $db = JFactory::getDBO(); $order = JSFactory::getTable('order', 'jshop'); $jshopConfig->user_field_title[0] = ''; $jshopConfig->user_field_client_type[0] = ''; $file_generete_pdf_order = $jshopConfig->file_generete_pdf_order; $tmp_fields = $jshopConfig->getListFieldsRegister(); $config_fields = $tmp_fields["address"]; $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('address'); $order->load($order_id); $status = JSFactory::getTable('orderStatus', 'jshop'); $status->load($order->order_status); $name = $lang->get("name"); $order->status = $status->{$name}; $order->order_date = strftime($jshopConfig->store_date_format, strtotime($order->order_date)); $order->products = $order->getAllItems(); $order->weight = $order->getWeightItems(); if ($jshopConfig->show_delivery_time_checkout) { $deliverytimes = JSFactory::getAllDeliveryTime(); $order->order_delivery_time = $deliverytimes[$order->delivery_times_id]; if ($order->order_delivery_time == "") { $order->order_delivery_time = $order->delivery_time; } } $order->order_tax_list = $order->getTaxExt(); $show_percent_tax = 0; if (count($order->order_tax_list) > 1 || $jshopConfig->show_tax_in_product) { $show_percent_tax = 1; } if ($jshopConfig->hide_tax) { $show_percent_tax = 0; } $hide_subtotal = 0; if (($jshopConfig->hide_tax || count($order->order_tax_list) == 0) && $order->order_discount == 0 && $jshopConfig->without_shipping && $order->order_payment == 0) { $hide_subtotal = 1; } if ($order->weight == 0 && $jshopConfig->hide_weight_in_cart_weight0) { $jshopConfig->show_weight_order = 0; } $country = JSFactory::getTable('country', 'jshop'); $country->load($order->country); $field_country_name = $lang->get("name"); $order->country = $country->{$field_country_name}; $d_country = JSFactory::getTable('country', 'jshop'); $d_country->load($order->d_country); $field_country_name = $lang->get("name"); $order->d_country = $d_country->{$field_country_name}; if ($jshopConfig->show_delivery_date && !datenull($order->delivery_date)) { $order->delivery_date_f = formatdate($order->delivery_date); } else { $order->delivery_date_f = ''; } $order->title = $jshopConfig->user_field_title[$order->title]; $order->d_title = $jshopConfig->user_field_title[$order->d_title]; $order->birthday = getDisplayDate($order->birthday, $jshopConfig->field_birthday_format); $order->d_birthday = getDisplayDate($order->d_birthday, $jshopConfig->field_birthday_format); $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type]; $shippingMethod = JSFactory::getTable('shippingMethod', 'jshop'); $shippingMethod->load($order->shipping_method_id); $pm_method = JSFactory::getTable('paymentMethod', 'jshop'); $pm_method->load($order->payment_method_id); $paymentsysdata = $pm_method->getPaymentSystemData(); $payment_system = $paymentsysdata->paymentSystem; $name = $lang->get("name"); $description = $lang->get("description"); $order->shipping_information = $shippingMethod->{$name}; $shippingForm = $shippingMethod->getShippingForm(); if ($shippingForm) { $shippingForm->prepareParamsDispayMail($order, $shippingMethod); } $order->payment_name = $pm_method->{$name}; $order->payment_information = $order->payment_params; if ($payment_system) { $payment_system->prepareParamsDispayMail($order, $pm_method); } if ($pm_method->show_descr_in_email) { $order->payment_description = $pm_method->{$description}; } else { $order->payment_description = ""; } $statictext = JSFactory::getTable("statictext", "jshop"); $rowstatictext = $statictext->loadData("order_email_descr"); $order_email_descr = $rowstatictext->text; $order_email_descr = str_replace("{name}", $order->f_name, $order_email_descr); $order_email_descr = str_replace("{family}", $order->l_name, $order_email_descr); $order_email_descr = str_replace("{email}", $order->email, $order_email_descr); $order_email_descr = str_replace("{title}", $order->title, $order_email_descr); $rowstatictext = $statictext->loadData("order_email_descr_end"); $order_email_descr_end = $rowstatictext->text; $order_email_descr_end = str_replace("{name}", $order->f_name, $order_email_descr_end); $order_email_descr_end = str_replace("{family}", $order->l_name, $order_email_descr_end); $order_email_descr_end = str_replace("{email}", $order->email, $order_email_descr_end); $order_email_descr_end = str_replace("{title}", $order->title, $order_email_descr_end); if ($jshopConfig->show_return_policy_text_in_email_order) { $list = $order->getReturnPolicy(); $listtext = array(); foreach ($list as $v) { $listtext[] = $v->text; } $rptext = implode('<div class="return_policy_space"></div>', $listtext); $order_email_descr_end = $rptext . $order_email_descr_end; } $text_total = _JSHOP_ENDTOTAL; if (($jshopConfig->show_tax_in_product || $jshopConfig->show_tax_product_in_cart) && count($order->order_tax_list) > 0) { $text_total = _JSHOP_ENDTOTAL_INKL_TAX; } $uri = JURI::getInstance(); $liveurlhost = $uri->toString(array("scheme", 'host', 'port')); if ($jshopConfig->admin_show_vendors) { $listVendors = $order->getVendors(); } else { $listVendors = array(); } $vendors_send_message = $jshopConfig->vendor_order_message_type == 1; $vendor_send_order = $jshopConfig->vendor_order_message_type == 2; $vendor_send_order_admin = $jshopConfig->vendor_order_message_type == 2 && $order->vendor_type == 0 && $order->vendor_id || $jshopConfig->vendor_order_message_type == 3; if ($vendor_send_order_admin) { $vendor_send_order = 0; } $admin_send_order = 1; if ($jshopConfig->admin_not_send_email_order_vendor_order && $vendor_send_order_admin && count($listVendors)) { $admin_send_order = 0; } $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeSendEmailsOrder', array(&$order, &$listVendors, &$file_generete_pdf_order, &$admin_send_order)); //client message include_once JPATH_COMPONENT_SITE . "/views/checkout/view.html.php"; $view_name = "checkout"; $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name); $view = new JshoppingViewCheckout($view_config); $view->setLayout("orderemail"); $view->assign('client', 1); $view->assign('show_customer_info', 1); $view->assign('show_weight_order', 1); $view->assign('show_total_info', 1); $view->assign('show_payment_shipping_info', 1); $view->assign('config_fields', $config_fields); $view->assign('count_filed_delivery', $count_filed_delivery); $view->assign('order_email_descr', $order_email_descr); $view->assign('order_email_descr_end', $order_email_descr_end); $view->assign('config', $jshopConfig); $view->assign('order', $order); $view->assign('products', $order->products); $view->assign('show_percent_tax', $show_percent_tax); $view->assign('hide_subtotal', $hide_subtotal); $view->assign('noimage', $jshopConfig->noimage); $view->assign('text_total', $text_total); $view->assign('liveurlhost', $liveurlhost); $dispatcher->trigger('onBeforeCreateTemplateOrderMail', array(&$view)); $message_client = $view->loadTemplate(); //admin message $view_name = "checkout"; $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name); $view = new JshoppingViewCheckout($view_config); $view->setLayout("orderemail"); $view->assign('client', 0); $view->assign('show_customer_info', 1); $view->assign('show_weight_order', 1); $view->assign('show_total_info', 1); $view->assign('show_payment_shipping_info', 1); $view->assign('config_fields', $config_fields); $view->assign('count_filed_delivery', $count_filed_delivery); $view->assign('order_email_descr', $order_email_descr); $view->assign('order_email_descr_end', $order_email_descr_end); $view->assign('config', $jshopConfig); $view->assign('order', $order); $view->assign('products', $order->products); $view->assign('show_percent_tax', $show_percent_tax); $view->assign('hide_subtotal', $hide_subtotal); $view->assign('noimage', $jshopConfig->noimage); $view->assign('text_total', $text_total); $view->assign('liveurlhost', $liveurlhost); $dispatcher->trigger('onBeforeCreateTemplateOrderMail', array(&$view)); $message_admin = $view->loadTemplate(); //vendors messages or order if ($vendors_send_message || $vendor_send_order) { foreach ($listVendors as $k => $datavendor) { if ($vendors_send_message) { $show_customer_info = 0; $show_weight_order = 0; $show_total_info = 0; $show_payment_shipping_info = 0; } if ($vendor_send_order) { $show_customer_info = 1; $show_weight_order = 0; $show_total_info = 0; $show_payment_shipping_info = 1; } $vendor_order_items = $order->getVendorItems($datavendor->id); $view_name = "checkout"; $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name); $view = new JshoppingViewCheckout($view_config); $view->setLayout("orderemail"); $view->assign('client', 0); $view->assign('show_customer_info', $show_customer_info); $view->assign('show_weight_order', $show_weight_order); $view->assign('show_total_info', $show_total_info); $view->assign('show_payment_shipping_info', $show_payment_shipping_info); $view->assign('config_fields', $config_fields); $view->assign('count_filed_delivery', $count_filed_delivery); $view->assign('order_email_descr', $order_email_descr); $view->assign('order_email_descr_end', $order_email_descr_end); $view->assign('config', $jshopConfig); $view->assign('order', $order); $view->assign('products', $vendor_order_items); $view->assign('show_percent_tax', $show_percent_tax); $view->assign('hide_subtotal', $hide_subtotal); $view->assign('noimage', $jshopConfig->noimage); $view->assign('text_total', $text_total); $view->assign('liveurlhost', $liveurlhost); $view->assign('show_customer_info', $vendor_send_order); $dispatcher->trigger('onBeforeCreateTemplateOrderPartMail', array(&$view)); $message_vendor = $view->loadTemplate(); $listVendors[$k]->message = $message_vendor; } } $pdfsend = 1; if ($jshopConfig->send_invoice_manually && !$manuallysend) { $pdfsend = 0; } if ($pdfsend && ($jshopConfig->order_send_pdf_client || $jshopConfig->order_send_pdf_admin)) { include_once $file_generete_pdf_order; $order->setInvoiceDate(); $order->pdf_file = generatePdf($order, $jshopConfig); $order->insertPDF(); } $mailfrom = $mainframe->getCfg('mailfrom'); $fromname = $mainframe->getCfg('fromname'); //send mail client if ($order->email) { $mailer = JFactory::getMailer(); $mailer->setSender(array($mailfrom, $fromname)); $mailer->addRecipient($order->email); $mailer->setSubject(sprintf(_JSHOP_NEW_ORDER, $order->order_number, $order->f_name . " " . $order->l_name)); $mailer->setBody($message_client); if ($pdfsend && $jshopConfig->order_send_pdf_client) { $mailer->addAttachment($jshopConfig->pdf_orders_path . "/" . $order->pdf_file); } $mailer->isHTML(true); $dispatcher->trigger('onBeforeSendOrderEmailClient', array(&$mailer, &$order, &$manuallysend, &$pdfsend)); $send = $mailer->Send(); } //send mail admin if ($admin_send_order) { $mailer = JFactory::getMailer(); $mailer->setSender(array($mailfrom, $fromname)); $mailer->addRecipient(explode(',', $jshopConfig->contact_email)); $mailer->setSubject(sprintf(_JSHOP_NEW_ORDER, $order->order_number, $order->f_name . " " . $order->l_name)); $mailer->setBody($message_admin); if ($pdfsend && $jshopConfig->order_send_pdf_admin) { $mailer->addAttachment($jshopConfig->pdf_orders_path . "/" . $order->pdf_file); } $mailer->isHTML(true); $dispatcher->trigger('onBeforeSendOrderEmailAdmin', array(&$mailer, &$order, &$manuallysend, &$pdfsend)); $send = $mailer->Send(); } //send mail vendors if ($vendors_send_message || $vendor_send_order) { foreach ($listVendors as $k => $vendor) { $mailer = JFactory::getMailer(); $mailer->setSender(array($mailfrom, $fromname)); $mailer->addRecipient($vendor->email); $mailer->setSubject(sprintf(_JSHOP_NEW_ORDER_V, $order->order_number, "")); $mailer->setBody($vendor->message); $mailer->isHTML(true); $dispatcher->trigger('onBeforeSendOrderEmailVendor', array(&$mailer, &$order, &$manuallysend, &$pdfsend, &$vendor, &$vendors_send_message, &$vendor_send_order)); $send = $mailer->Send(); } } //vendor send order if ($vendor_send_order_admin) { foreach ($listVendors as $k => $vendor) { $mailer = JFactory::getMailer(); $mailer->setSender(array($mailfrom, $fromname)); $mailer->addRecipient($vendor->email); $mailer->setSubject(sprintf(_JSHOP_NEW_ORDER, $order->order_number, $order->f_name . " " . $order->l_name)); $mailer->setBody($message_admin); if ($pdfsend && $jshopConfig->order_send_pdf_admin) { $mailer->addAttachment($jshopConfig->pdf_orders_path . "/" . $order->pdf_file); } $mailer->isHTML(true); $dispatcher->trigger('onBeforeSendOrderEmailVendorOrder', array(&$mailer, &$order, &$manuallysend, &$pdfsend, &$vendor, &$vendors_send_message, &$vendor_send_order)); $send = $mailer->Send(); } } $dispatcher->trigger('onAfterSendEmailsOrder', array(&$order)); }
private function x0b() { global $x15d, $x15e, $x15f, $x160, $x161, $x162, $x163, $x164, $x165, $x166, $x167, $x168, $x169, $x16a, $x16b, $x16c, $x16d, $x16e, $x16f, $x170, $x171, $x172, $x173, $x174, $x175, $x176, $x177, $x178; $x2b = "vtiger_current_version"; $x2c = vglobal($x2b); $x40 = "_fieldinfo_cache"; $x3d = "SELECT fieldid, relmodule FROM vtiger_fieldmodulerel"; $x3e = self::$x0f->query($x3d); $x41 = array(); while ($x42 = self::$x0f->fetchByAssoc($x3e)) { $x41[$x42["fieldid"]][] = $x42["relmodule"]; } $x3d = "SELECT fieldid, fieldname, uitype, columnname\n\n FROM vtiger_field\r\n WHERE tabid=" . getTabId(self::$x0c) . " AND (displaytype != 3 OR fieldid = 64)"; $x3e = self::$x0f->query($x3d); $x43 = self::$x0f->num_rows($x3e); if ($x43 > 0) { $x44 = array(); $x45 = $x16a(getTabId("Tac4you")); if ($x45 == true) { $x46 = "SELECT tac4you_module FROM vtiger_tac4you_module WHERE presence = 1"; $x47 = self::$x0f->query($x46); while ($x48 = self::$x0f->fetchByAssoc($x47)) { $x44[$x48["tac4you_module"]] = $x48["tac4you_module"]; } } $x49 = array(); $x4a = $x16a(getTabId("Descriptions4you")); if ($x4a == true) { $x4b = "SELECT b.name FROM vtiger_links AS a\r\n INNER JOIN vtiger_tab AS b USING (tabid)\n\n WHERE linktype = 'DETAILVIEWWIDGET'\r\n AND linkurl = 'block://ModDescriptions4you:modules/Descriptions4you/ModDescriptions4you.php'"; $x4c = self::$x0f->query($x4b); while ($x4d = self::$x0f->fetchByAssoc($x4c)) { $x49[$x4d["name"]] = $x4d["name"]; } } while ($x42 = self::$x0f->fetch_array($x3e)) { $x4e = ""; $x4f = $x42["columnname"]; $x50 = self::$x0e->column_fields[$x42["fieldname"]]; switch ($x42["uitype"]) { case "51": $x4e = "Accounts"; break; case "57": $x4e = "Contacts"; break; case "58": $x4e = "Campaigns"; break; case "59": $x4e = "Products"; break; case "73": $x4e = "Accounts"; break; case "75": $x4e = "Vendors"; break; case "81": $x4e = "Vendors"; break; case "76": $x4e = "Potentials"; break; case "78": $x4e = "Quotes"; break; case "80": $x4e = "SalesOrder"; break; case "68": case "10": $x4e = getSalesEntityType($x50); break; } if ($x4e != "") { $x51 = getTabId($x4e); $x52 =& VTCacheUtils::${$x40}; unset($x52[$x51]); $x53 = CRMEntity::getInstance($x4e); if ($x50 != "" && $x50 != "0") { $x54 = self::$x0f->query("SELECT deleted FROM vtiger_crmentity WHERE crmid='" . $x50 . "' AND deleted=0"); if (self::$x0f->num_rows($x54) > 0) { $x53->retrieve_entity_info($x50, $x4e); $x53->id = $x50; } } self::$x21["\$" . "R_" . $x175($x4e) . "_CRMID\$"] = $x53->id; self::$x21["\$" . "R_" . $x175($x4f) . "_CRMID\$"] = $x53->id; if ($x2c == '5.2.1') { $x36 = getDisplayDate($x53->column_fields['createdtime']); $x37 = getDisplayDate($x53->column_fields['modifiedtime']); } else { $x38 = new DateTimeField($x53->column_fields['createdtime']); $x36 = $x38->getDisplayDateTimeValue(); $x39 = new DateTimeField($x53->column_fields['modifiedtime']); $x37 = $x39->getDisplayDateTimeValue(); } self::$x21["\$" . "R_" . $x175($x4e) . "_CREATEDTIME_DATETIME\$"] = $x36; self::$x21["\$" . "R_" . $x175($x4f) . "_CREATEDTIME_DATETIME\$"] = $x36; self::$x21["\$" . "R_" . $x175($x4e) . "_MODIFIEDTIME_DATETIME\$"] = $x37; self::$x21["\$" . "R_" . $x175($x4f) . "_MODIFIEDTIME_DATETIME\$"] = $x37; if (isset($x4e)) { $x55 = ""; switch ($x4e) { case "Contacts": $x55 = $this->x1b($x53->id); break; case "Products": $x55 = $this->x1d($x53->id); break; } self::$x21['$x56' . $x175($x4e) . '_IMAGENAME$'] = $x55; self::$x21['$x56' . $x175($x4f) . '_IMAGENAME$'] = $x55; } if (isset($x44[$x4e])) { $x46 = "SELECT text FROM vtiger_tac4you_texts WHERE id=?"; $x47 = self::$x0f->pquery($x46, array($x53->id)); $x57 = self::$x0f->query_result($x47, 0, "text"); $x57 = $x165($x57, ENT_QUOTES, self::$x11); self::$x21["\$" . "R_" . $x175($x4e) . "_TAC4YOU\$"] = $x57; self::$x21["\$" . "R_" . $x175($x4f) . "_TAC4YOU\$"] = $x57; } if (isset($x49[$x4e])) { $x4b = "SELECT text FROM vtiger_descriptions4you_texts WHERE id=?"; $x4c = self::$x0f->pquery($x4b, array($x53->id)); $x58 = self::$x0f->query_result($x4c, 0, "text"); $x58 = $x165($x58, ENT_QUOTES, self::$x11); self::$x21["\$" . "R_" . $x175($x4e) . "_DESC4YOU\$"] = $x58; self::$x21["\$" . "R_" . $x175($x4f) . "_DESC4YOU\$"] = $x58; } if (isset($x59[$x4e])) { $x5a = $this->x2d($x53->id); $x5a = $x165($x5a, ENT_QUOTES, self::$x11); self::$x21["\$" . "R_" . $x175($x4f) . "_MODCOMMENTS\$"] = $x5a; } $this->x15(); $this->x10($x4e, $x53, true); $this->x10($x4e, $x53, $x4f); $this->x2f($x4e, $x53, $x4f); unset($x53); } if ($x42["uitype"] == "68") { $x41[$x42["fieldid"]][] = "Contacts"; $x41[$x42["fieldid"]][] = "Accounts"; } if (isset($x41[$x42["fieldid"]])) { foreach ($x41[$x42["fieldid"]] as $x5b => $x5c) { if ($x5c == $x4e) { continue; } $x5d = getTabId($x5c); $x52 =& VTCacheUtils::${$x40}; unset($x52[$x5d]); if ($x164("modules/" . $x5c . "/" . $x5c . ".php")) { $x5e = CRMEntity::getInstance($x5c); self::$x21["\$" . "R_" . $x175($x5c) . "_CRMID\$"] = $x5e->id; self::$x21["\$" . "R_" . $x175($x4f) . "_CRMID\$"] = $x5e->id; if ($x2c == '5.2.1') { $x36 = getDisplayDate($x5e->column_fields['createdtime']); $x37 = getDisplayDate($x5e->column_fields['modifiedtime']); } else { $x38 = new DateTimeField($x5e->column_fields['createdtime']); $x36 = $x38->getDisplayDateTimeValue(); $x39 = new DateTimeField($x5e->column_fields['modifiedtime']); $x37 = $x39->getDisplayDateTimeValue(); } self::$x21["\$" . "R_" . $x175($x5c) . "_CREATEDTIME_DATETIME\$"] = $x36; self::$x21["\$" . "R_" . $x175($x4f) . "_CREATEDTIME_DATETIME\$"] = $x36; self::$x21["\$" . "R_" . $x175($x5c) . "_MODIFIEDTIME_DATETIME\$"] = $x37; self::$x21["\$" . "R_" . $x175($x4f) . "_MODIFIEDTIME_DATETIME\$"] = $x37; $this->x10($x5c, $x5e, true); $this->x10($x5c, $x5e, $x4f); $this->x2f($x5c, $x5e, $x4f); unset($x5e); } } } } } }
/** to get the Fenzu stdFilter Query for the given Fenzu Id * @param $cvid :: Type Integer * @returns $stdfiltersql as a string * This function will return the standard filter criteria for the given customfield * */ function getCVStdFilterSQL($cvid) { global $adb; $stdfiltersql = ""; $stdfilterlist = $this->getStdFilterByCvid($cvid); if (isset($stdfilterlist)) { foreach ($stdfilterlist as $columnname => $value) { if ($columnname == "columnname") { $filtercolumn = $value; } elseif ($columnname == "stdfilter") { $filtertype = $value; } elseif ($columnname == "startdate") { $startdate = $value; } elseif ($columnname == "enddate") { $enddate = $value; } } if ($filtertype != "custom") { $datearray = $this->getDateforStdFilterBytype($filtertype); $startdate = $datearray[0]; $enddate = $datearray[1]; } if (isset($startdate) && $startdate != "" && isset($enddate) && $enddate != "") { $startdate = getDisplayDate($startdate); $enddate = getDisplayDate($enddate); $columns = explode(":", $filtercolumn); if ($columns[1] == 'birthday') { $startdate_tmp = substr($startdate, -5); $enddate_tmp = substr($enddate, -5); if ($startdate_tmp == $enddate_tmp) { $stdfiltersql = $columns[0] . "." . $columns[1] . " like '%" . $startdate_tmp . "%'"; } elseif ($startdate_tmp < $enddate_tmp) { $stdfiltersql = " (DATE_FORMAT(" . $columns[0] . "." . $columns[1] . ",'%m-%d')) >= '" . $startdate_tmp . "' and (DATE_FORMAT(" . $columns[0] . "." . $columns[1] . ",'%m-%d')) <= '" . $enddate_tmp . "' "; } elseif ($startdate_tmp > $enddate_tmp) { $stdfiltersql = " (DATE_FORMAT(" . $columns[0] . "." . $columns[1] . ",'%m-%d')) <= '" . $startdate_tmp . "' and (DATE_FORMAT(" . $columns[0] . "." . $columns[1] . ",'%m-%d')) >= '" . $enddate_tmp . "' "; } else { $stdfiltersql = ''; } } else { if ($startdate != "" && $enddate != "") { $stdfiltersql = $columns[0] . "." . $columns[1] . " between '" . $startdate . " 00:00:00' and '" . $enddate . " 23:59:00'"; } elseif ($startdate == "" && $enddate != "") { $stdfiltersql = $columns[0] . "." . $columns[1] . " < '" . $enddate . " 23:59:00'"; } elseif ($startdate != "" && $enddate == "") { $stdfiltersql = $columns[0] . "." . $columns[1] . " > '" . $startdate . " 00:00:00'"; } else { $stdfiltersql = ""; } } } } return $stdfiltersql; }
function order() { $jshopConfig = JSFactory::getConfig(); checkUserLogin(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $lang = JSFactory::getLang(); JPluginHelper::importPlugin('jshoppingorder'); $dispatcher = JDispatcher::getInstance(); appendPathWay(_JSHOP_MY_ORDERS, SEFLink('index.php?option=com_jshopping&controller=user&task=orders', 0, 0, $jshopConfig->use_ssl)); $seo = JTable::getInstance("seo", "jshop"); $seodata = $seo->loadData("myorder-detail"); if ($seodata->title == "") { $seodata->title = _JSHOP_MY_ORDERS; } setMetaData($seodata->title, $seodata->keyword, $seodata->description); $order_id = JRequest::getInt('order_id'); $order = JTable::getInstance('order', 'jshop'); $order->load($order_id); $dispatcher->trigger('onAfterLoadOrder', array(&$order, &$user)); appendPathWay(_JSHOP_ORDER_NUMBER . ": " . $order->order_number); if ($user->id != $order->user_id) { JError::raiseError(500, "Error order number. You are not the owner of this order"); } $order->items = $order->getAllItems(); $order->weight = $order->getWeightItems(); $order->status_name = $order->getStatus(); $order->history = $order->getHistory(); if ($jshopConfig->client_allow_cancel_order && $order->order_status != $jshopConfig->payment_status_for_cancel_client && !in_array($order->order_status, $jshopConfig->payment_status_disable_cancel_client)) { $allow_cancel = 1; } else { $allow_cancel = 0; } $order->birthday = getDisplayDate($order->birthday, $jshopConfig->field_birthday_format); $order->d_birthday = getDisplayDate($order->d_birthday, $jshopConfig->field_birthday_format); $shipping_method = JTable::getInstance('shippingMethod', 'jshop'); $shipping_method->load($order->shipping_method_id); $name = $lang->get("name"); $description = $lang->get("description"); $order->shipping_info = $shipping_method->{$name}; $pm_method = JTable::getInstance('paymentMethod', 'jshop'); $pm_method->load($order->payment_method_id); $order->payment_name = $pm_method->{$name}; if ($pm_method->show_descr_in_email) { $order->payment_description = $pm_method->{$description}; } else { $order->payment_description = ""; } $country = JTable::getInstance('country', 'jshop'); $country->load($order->country); $field_country_name = $lang->get("name"); $order->country = $country->{$field_country_name}; $d_country = JTable::getInstance('country', 'jshop'); $d_country->load($order->d_country); $field_country_name = $lang->get("name"); $order->d_country = $d_country->{$field_country_name}; $jshopConfig->user_field_client_type[0] = ""; $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type]; $order->delivery_time_name = ''; $order->delivery_date_f = ''; if ($jshopConfig->show_delivery_time_checkout) { $deliverytimes = JSFactory::getAllDeliveryTime(); $order->delivery_time_name = $deliverytimes[$order->delivery_times_id]; if ($order->delivery_time_name == "") { $order->delivery_time_name = $order->delivery_time; } } if ($jshopConfig->show_delivery_date && !datenull($order->delivery_date)) { $order->delivery_date_f = formatdate($order->delivery_date); } $order->order_tax_list = $order->getTaxExt(); $show_percent_tax = 0; if (count($order->order_tax_list) > 1 || $jshopConfig->show_tax_in_product) { $show_percent_tax = 1; } if ($jshopConfig->hide_tax) { $show_percent_tax = 0; } $hide_subtotal = 0; if (($jshopConfig->hide_tax || count($order->order_tax_list) == 0) && $order->order_discount == 0 && $order->order_payment == 0 && $jshopConfig->without_shipping) { $hide_subtotal = 1; } $text_total = _JSHOP_ENDTOTAL; if (($jshopConfig->show_tax_in_product || $jshopConfig->show_tax_product_in_cart) && count($order->order_tax_list) > 0) { $text_total = _JSHOP_ENDTOTAL_INKL_TAX; } $tmp_fields = $jshopConfig->getListFieldsRegister(); $config_fields = $tmp_fields["address"]; $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('address'); if ($jshopConfig->order_display_new_digital_products) { $product = JTable::getInstance('product', 'jshop'); foreach ($order->items as $k => $v) { $product->product_id = $v->product_id; $product->setAttributeActive(unserialize($v->attributes)); $files = $product->getSaleFiles(); $order->items[$k]->files = serialize($files); } } $dispatcher->trigger('onBeforeDisplayOrder', array(&$order)); $view_name = "order"; $view_config = array("template_path" => JPATH_COMPONENT . "/templates/" . $jshopConfig->template . "/" . $view_name); $view = $this->getView($view_name, getDocumentType(), '', $view_config); $view->setLayout("order"); $view->assign('order', $order); $view->assign('config', $jshopConfig); $view->assign('text_total', $text_total); $view->assign('show_percent_tax', $show_percent_tax); $view->assign('hide_subtotal', $hide_subtotal); $view->assign('image_path', $jshopConfig->live_path . "images"); $view->assign('config_fields', $config_fields); $view->assign('count_filed_delivery', $count_filed_delivery); $view->assign('allow_cancel', $allow_cancel); $dispatcher->trigger('onBeforeDisplayOrderView', array(&$view)); $view->display(); }
echo $this->users_list_select; ?> </div> </div> <?php if ($this->config->date_invoice_in_invoice) { ?> <div class="row-fluid"> <div class="span2"><?php print _JSHOP_INVOICE_DATE; ?> :</div> <div class="span10"><?php echo JHTML::_('calendar', getDisplayDate($order->invoice_date, $this->config->store_date_format), 'invoice_date', 'invoice_date', $this->config->store_date_format, array('class' => 'inputbox', 'size' => '25', 'maxlength' => '19')); ?> </div> </div> <?php } ?> <table class="jshop_address" width="100%"> <tr> <td width="50%" valign="top"> <table width="100%" class="admintable table table-striped"> <thead> <tr> <th colspan="2" align="center"><?php print _JSHOP_BILL_TO;