Esempio n. 1
0
 function getNewCvListQuery($viewid, $listquery, $module, $is_popup = false)
 {
     $entityArr = getEntityTable($module);
     $ec_crmentity = $entityArr["tablename"];
     $entityidfield = $entityArr["entityidfield"];
     $crmid = $ec_crmentity . "." . $entityidfield;
     if (!$is_popup) {
         $key = "cvlistquery" . $module . "_" . $viewid;
         $query = getSqlCacheData($key);
         if (!$query) {
             $fieldquery = $this->getNewCvColumnListSQL($viewid);
             if ($viewid != "" && $listquery != "" && $fieldquery != "") {
                 $listviewquery = substr($listquery, strpos($listquery, 'FROM'), strlen($listquery));
                 if ($module != "Calendar") {
                     $query = "select " . $fieldquery . " ," . $crmid . " as crmid " . $listviewquery;
                 } else {
                     $query = "select " . $fieldquery . " ," . $crmid . " as crmid,ec_activity.* " . $listviewquery;
                 }
                 $stdfiltersql = $this->getCVStdFilterSQL($viewid);
                 $advfiltersql = $this->getCVAdvFilterSQL($viewid);
                 if (isset($stdfiltersql) && $stdfiltersql != '' && $stdfiltersql != '()') {
                     $query .= ' and ' . $stdfiltersql;
                 }
                 if (isset($advfiltersql) && $advfiltersql != '' && $advfiltersql != '()') {
                     $query .= ' and ' . $advfiltersql;
                 }
             } else {
                 $query = $listquery;
             }
             setSqlCacheData($key, $query);
         }
     } else {
         $query = $listquery;
         if ($viewid != "") {
             $stdfiltersql = $this->getCVStdFilterSQL($viewid);
             $advfiltersql = $this->getCVAdvFilterSQL($viewid);
             if (isset($stdfiltersql) && $stdfiltersql != '') {
                 $query .= ' and ' . $stdfiltersql;
             }
             if (isset($advfiltersql) && $advfiltersql != '') {
                 $query .= ' and ' . $advfiltersql;
             }
         }
     }
     return $query;
 }
Esempio n. 2
0
    if (isset($_REQUEST['fldMandatory'])) {
        $fldMandatory = $_REQUEST['fldMandatory'];
    } else {
        $fldMandatory = '';
    }
    redirect("index.php?module=Settings&action=CustomFieldList&fld_module=" . $fldmodule . "&fldType=" . $fldType . "&fldlabel=" . $fldlabel . "&fldlength=" . $fldlength . "&flddecimal=" . $flddecimal . "&fldPickList=" . $fldPickList . "&parenttab=" . $parenttab . "&duplicate=yes");
} else {
    if ($_REQUEST['fieldid'] == '') {
        $max_fieldid = $adb->getUniqueID("ec_field");
        $columnName = 'cf_' . $max_fieldid;
    } else {
        $max_fieldid = $_REQUEST['column'];
        $columnName = $max_fieldid;
    }
    $fieldName = $columnName;
    $entityArr = getEntityTable($fldmodule);
    $tableName = $entityArr["tablename"];
    //Assigning the uitype
    $fldlength = $_REQUEST['fldLength'];
    $uitype = '';
    $fldPickList = '';
    if (isset($_REQUEST['fldDecimal']) && $_REQUEST['fldDecimal'] != '') {
        $decimal = $_REQUEST['fldDecimal'];
    } else {
        $decimal = 0;
    }
    if (isset($_REQUEST['fldMandatory'])) {
        $fldMandatory = $_REQUEST['fldMandatory'];
    } else {
        $fldMandatory = '';
    }
Esempio n. 3
0
/** Function to get a user id or group id for a given entity
 * @param $record -- entity id :: Type integer
 * @returns $ownerArr -- owner id :: Type array 
 */
function getRecordOwnerId($module, $record)
{
    global $log;
    $log->debug("Entering getRecordOwnerId() method ...");
    global $adb;
    if ($record == 0) {
        return 0;
    }
    $entityArr = getEntityTable($module);
    $tablename = $entityArr["tablename"];
    $entityidfield = $entityArr["entityidfield"];
    $query = "select smownerid from " . $tablename . " where " . $entityidfield . " = " . $record;
    $result = $adb->query($query);
    $user_id = $adb->query_result($result, 0, 'smownerid');
    if ($user_id != 0) {
        return $user_id;
    }
    $log->debug("Exiting getRecordOwnerId method ...");
    return 0;
}
Esempio n. 4
0
 function saveentity($module)
 {
     global $current_user;
     $insertion_mode = $this->mode;
     $this->db->println("TRANS saveentity starts {$module}");
     $this->db->startTransaction();
     $key = "approvemodulelist";
     $appmoduleArr = getSqlCacheData($key);
     if (!$appmoduleArr) {
         $appmoduleArr = array();
         $result = $this->db->query("select ec_modulelist.*,ec_tab.name from ec_modulelist inner join ec_tab on ec_tab.tabid=ec_modulelist.tabid where ec_modulelist.type='approve' order by ec_tab.tabid");
         $num_rows = $this->db->num_rows($result);
         for ($i = 0; $i < $num_rows; $i++) {
             $appmodulename = $this->db->query_result($result, $i, 'name');
             $appmoduleArr[] = $appmodulename;
         }
         setSqlCacheData($key, $appmoduleArr);
     }
     if (in_array($module, $appmoduleArr)) {
         $this->isModuleApprove = true;
     }
     if ($this->isModuleApprove && $this->mode == "edit" && $_REQUEST['assigntype'] != 'T' && !empty($this->id)) {
         $entityArr = getEntityTable($module);
         $entityidfield = $entityArr["entityidfield"];
         $ec_crmentity = $entityArr["tablename"];
         $ownersql = "select smownerid from {$ec_crmentity} where {$entityidfield}='" . $this->id . "' and deleted=0";
         $ownerid = $this->db->getOne($ownersql);
         $newownerid = $this->column_fields['assigned_user_id'];
         if ($ownerid != $newownerid) {
             $ownername = getUserName($newownerid);
         }
     }
     if (!$this->isModuleApprove) {
         foreach ($this->tab_name as $table_name) {
             if ($table_name == "ec_crmentity") {
                 $this->insertIntoCrmEntity($module);
             } else {
                 $this->insertIntoEntityTable($table_name, $module);
             }
         }
     } else {
         foreach ($this->tab_name as $table_name) {
             if ($table_name == "ec_crmentity") {
                 $this->insertIntoCrmEntity($module);
             } else {
                 $this->insertIntoAppEntityTable($table_name, $module);
             }
         }
     }
     //Calling the Module specific save code
     $this->save_module($module);
     if ($this->isModuleApprove && $this->mode != "edit" && substr($_REQUEST['action'], -4) != 'Ajax' && $_REQUEST['ajxaction'] != 'DETAILVIEW') {
     }
     $this->db->completeTransaction();
     $this->db->println("TRANS saveentity ends");
     // vtlib customization: Hook provide to enable generic module relation.
     if ($_REQUEST['return_action'] == 'CallRelatedList') {
         $for_module = $_REQUEST['return_module'];
         $for_crmid = $_REQUEST['return_id'];
         if (is_file("modules/{$for_module}/{$for_module}.php")) {
             require_once "modules/{$for_module}/{$for_module}.php";
             $on_focus = new $for_module();
             // Do conditional check && call only for Custom Module at present
             // TOOD: $on_focus->IsCustomModule is not required if save_related_module function
             // is used for core modules as well.
             if ($on_focus->is_custom_module && method_exists($on_focus, 'save_related_module')) {
                 $with_module = $module;
                 $with_crmid = $this->id;
                 $on_focus->save_related_module($for_module, $for_crmid, $with_module, $with_crmid);
             }
         }
     }
 }
Esempio n. 5
0
/**	Function to get the Tags where condition
 *	@param  string $search_val -- entered search string value
 *	@param  string $current_user_id     -- current user id
 *	@return string $where      -- where condition with the list of crmids, will like ec_crmentity.crmid in (1,3,4,etc.,)
 */
function getTagWhere($search_val, $current_user_id, $search_module = '')
{
    require_once 'include/freetag/freetag.class.php';
    $freetag_obj = new freetag();
    $crmid_array = $freetag_obj->get_objects_with_tag_all($search_val, $current_user_id);
    $entityArr = getEntityTable($search_module);
    $ec_crmentity = $entityArr["tablename"];
    $entityidfield = $entityArr["entityidfield"];
    $crmid = $ec_crmentity . "." . $entityidfield;
    $where = '';
    if (count($crmid_array) > 0) {
        $where = $crmid . " IN (";
        foreach ($crmid_array as $index => $crmid) {
            $where .= $crmid . ',';
        }
        $where = trim($where, ',') . ')';
    }
    return $where;
}
Esempio n. 6
0
function export_all($type)
{
    global $log, $list_max_entries_per_page;
    $log->debug("Entering export_all(" . $type . ") method ...");
    global $adb;
    $focus = 0;
    $content = '';
    if ($type != "") {
        //changed by dingjianting on 2009-2-15 for supporting new module
        require_once "modules/{$type}/{$type}.php";
        $focus = new $type();
    }
    $log = LoggerManager::getLogger('export_' . $type);
    $where = '';
    /*
    
    if ( isset($_REQUEST['all']) )
    {
    	$where = '';
    }
    else
    {
    	$where = $_SESSION['export_where'];
    }
    */
    if (!isset($_REQUEST['allids']) || $_REQUEST['allids'] == "") {
        $where = "";
    } else {
        $allids = str_replace(";", ",", $_REQUEST['allids']);
        $allids = substr($allids, 0, -1);
        $where = $crmid . " in (" . $allids . ")";
    }
    $search_type = $_REQUEST['search_type'];
    $export_data = $_REQUEST['export_data'];
    $viewname = $_REQUEST['viewname'];
    $entityArr = getEntityTable($type);
    $ec_crmentity = $entityArr["tablename"];
    $entityidfield = $entityArr["entityidfield"];
    $crmid = $ec_crmentity . "." . $entityidfield;
    $order_by = "";
    $query = $focus->create_export_query($order_by, $where);
    if (isset($_SESSION['export_where']) && $_SESSION['export_where'] != '' && $search_type == 'includesearch') {
        $where = $_SESSION['export_where'];
        $query .= ' and  (' . $where . ') ';
    }
    if (($search_type == 'withoutsearch' || $search_type == 'includesearch') && $export_data == 'selecteddata') {
        $idstring = str_replace(";", ",", $_REQUEST['idstring']);
        $idstring = substr($idstring, 0, -1);
        if ($idstring != "") {
            $query .= ' and ' . $crmid . ' in (' . $idstring . ')';
        }
    }
    if ($export_data == 'vieweddata' && $viewname != "" && $viewname != 0) {
        $oCustomView = new CustomView($type);
        if ($type == "SalesOrder" || $type == "PurchaseOrder") {
            $query = $oCustomView->getExportModifiedCvListQuery($viewname, $query, $type, true);
            //getModifiedCvListQuery
        } else {
            $query = $oCustomView->getExportModifiedCvListQuery($viewname, $query, $type, false);
            //getModifiedCvListQuery
        }
    }
    if (isset($_SESSION['nav_start']) && $_SESSION['nav_start'] != '' && $export_data == 'currentpage') {
        $start_rec = $_SESSION['nav_start'];
        $limit_start_rec = $start_rec == 0 ? 0 : $start_rec - 1;
        $query_order_by = $crmid;
        $sorder = "desc";
        $result = $adb->limitQuery2($query, $limit_start_rec, $list_max_entries_per_page, $query_order_by, $sorder);
    } else {
        $query .= " order by " . $crmid . " desc";
        $result = $adb->query($query, true, "Error exporting {$type}: " . "<BR>{$query}");
    }
    $numRows = $adb->num_rows($result);
    $fields_array = $adb->getFieldsArray($result);
    global $current_language;
    $spec_mod_strings = return_specified_module_language($current_language, $type);
    foreach ($fields_array as $key => $fieldlabel) {
        if (isset($spec_mod_strings[$fieldlabel])) {
            $fields_array[$key] = $spec_mod_strings[$fieldlabel];
        }
    }
    $header = implode("\",\"", array_values($fields_array));
    $header = "\"" . $header;
    $header .= "\"\r\n";
    $content .= $header;
    $column_list = implode(",", array_values($fields_array));
    while ($val = $adb->fetchByAssoc($result, -1, false)) {
        $new_arr = array();
        foreach ($val as $key => $value) {
            if ($key == "description") {
                $value = br2nl_vt($value);
            }
            array_push($new_arr, preg_replace("/\"/", "\"\"", $value));
        }
        $line = implode("\",\"", $new_arr);
        $line = "\"" . $line;
        $line .= "\"\r\n";
        $content .= $line;
    }
    $log->debug("Exiting export_all method ...");
    return $content;
}
Esempio n. 7
0
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
*
 ********************************************************************************/
require_once 'include/database/PearDatabase.php';
require_once 'include/utils/UserInfoUtil.php';
require_once 'include/utils/CommonUtils.php';
$idlist = $_REQUEST['idlist'];
$viewid = $_REQUEST['viewname'];
$returnmodule = $_REQUEST['return_module'];
$return_action = $_REQUEST['return_action'];
//split the string and store in an array
$storearray = explode(";", $idlist);
array_filter($storearray);
$ids_list = array();
$modulerel = getEntityTable($returnmodule);
$tablename = $modulerel['tablename'];
$fieldid = $modulerel['entityidfield'];
foreach ($storearray as $id) {
    if (isPermitted($returnmodule, 'Delete', $id) == 'yes') {
        global $current_user;
        /*require_once('include/freetag/freetag.class.php');
          $freetag=new freetag();
          $freetag->delete_all_object_tags_for_user($current_user->id,$id);*/
        $date_var = date('YmdHis');
        $sql = "update " . $tablename . " set deleted=1,modifiedby='" . $current_user->id . "',modifiedtime=" . $adb->formatDate($date_var) . " where " . $fieldid . "='" . $id . "'";
        $result = $adb->query($sql);
    } else {
        $ids_list[] = $id;
    }
}