当前位置: 首页>>代码示例>>PHP>>正文


PHP getUniquePicklistID函数代码示例

本文整理汇总了PHP中getUniquePicklistID函数的典型用法代码示例。如果您正苦于以下问题:PHP getUniquePicklistID函数的具体用法?PHP getUniquePicklistID怎么用?PHP getUniquePicklistID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getUniquePicklistID函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addPickListValues

 public function addPickListValues($fieldModel, $newValue, $rolesSelected = array())
 {
     $db = PearDatabase::getInstance();
     $pickListFieldName = $fieldModel->getName();
     $id = $db->getUniqueID("vtiger_{$pickListFieldName}");
     vimport('~~/include/ComboUtil.php');
     $picklist_valueid = getUniquePicklistID();
     $tableName = 'vtiger_' . $pickListFieldName;
     $maxSeqQuery = 'SELECT max(sortorderid) as maxsequence FROM ' . $tableName;
     $result = $db->pquery($maxSeqQuery, array());
     $sequence = $db->query_result($result, 0, 'maxsequence');
     if ($fieldModel->isRoleBased()) {
         $sql = 'INSERT INTO ' . $tableName . ' VALUES (?,?,?,?,?)';
         $db->pquery($sql, array($id, $newValue, 1, $picklist_valueid, ++$sequence));
     } else {
         $sql = 'INSERT INTO ' . $tableName . ' VALUES (?,?,?,?)';
         $db->pquery($sql, array($id, $newValue, ++$sequence, 1));
     }
     if ($fieldModel->isRoleBased() && !empty($rolesSelected)) {
         $sql = "select picklistid from vtiger_picklist where name=?";
         $result = $db->pquery($sql, array($pickListFieldName));
         $picklistid = $db->query_result($result, 0, "picklistid");
         //add the picklist values to the selected roles
         for ($j = 0; $j < count($rolesSelected); $j++) {
             $roleid = $rolesSelected[$j];
             $sql = "SELECT max(sortid)+1 as sortid\n                       FROM vtiger_role2picklist left join vtiger_{$pickListFieldName}\n                           on vtiger_{$pickListFieldName}.picklist_valueid=vtiger_role2picklist.picklistvalueid\n                       WHERE roleid=? and picklistid=?";
             $sortid = $db->query_result($db->pquery($sql, array($roleid, $picklistid)), 0, 'sortid');
             $sql = "insert into vtiger_role2picklist values(?,?,?,?)";
             $db->pquery($sql, array($roleid, $picklist_valueid, $picklistid, $sortid));
         }
     }
     return $picklist_valueid;
 }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:33,代码来源:Module.php

示例2: insertComboValues

 /** 
  * To populate the default combo values for the combo vtiger_tables
  * @param $values -- values:: Type string array
  * @param $tableName -- tablename:: Type string 
  */
 function insertComboValues($values, $tableName, $picklistid)
 {
     global $log;
     $log->debug("Entering insertComboValues(" . $values . ", " . $tableName . ") method ...");
     global $adb;
     //inserting the value in the vtiger_picklistvalues_seq for the getting uniqueID for each picklist values...
     $i = 0;
     foreach ($values as $val => $cal) {
         $picklist_valueid = getUniquePicklistID();
         $id = $adb->getUniqueID('vtiger_' . $tableName);
         if ($val != '') {
             $params = array($id, $val, 1, $picklist_valueid);
             $adb->pquery("insert into vtiger_{$tableName} values(?,?,?,?)", $params);
         } else {
             $params = array($id, '--None--', 1, $picklist_valueid);
             $adb->pquery("insert into vtiger_{$tableName} values(?,?,?,?)", $params);
         }
         //Default entries for role2picklist relation has been inserted..
         $sql = "select roleid from vtiger_role";
         $role_result = $adb->pquery($sql, array());
         $numrow = $adb->num_rows($role_result);
         for ($k = 0; $k < $numrow; $k++) {
             $roleid = $adb->query_result($role_result, $k, 'roleid');
             $params = array($roleid, $picklist_valueid, $picklistid, $i);
             $adb->pquery("insert into vtiger_role2picklist values(?,?,?,?)", $params);
         }
         $i++;
     }
     $log->debug("Exiting insertComboValues method ...");
 }
开发者ID:sacredwebsite,项目名称:vtigercrm,代码行数:35,代码来源:PopulateComboValues.php

示例3: setPicklistValues

 /**
  * Set values for picklist field (for all the roles)
  * @param Array List of values to add.
  *
  * @internal Creates picklist base if it does not exists
  */
 function setPicklistValues($values)
 {
     global $adb;
     // Non-Role based picklist values
     if ($this->uitype == '16') {
         $this->setNoRolePicklistValues($values);
         return;
     }
     $picklist_table = 'vtiger_' . $this->name;
     $picklist_idcol = $this->name . 'id';
     if (!Vtiger_Utils::CheckTable($picklist_table)) {
         Vtiger_Utils::CreateTable($picklist_table, "({$picklist_idcol} INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t{$this->name} VARCHAR(200) NOT NULL,\n\t\t\t\tpresence INT (1) NOT NULL DEFAULT 1,\n\t\t\t\tpicklist_valueid INT NOT NULL DEFAULT 0)", true);
         $new_picklistid = $this->__getPicklistUniqueId();
         $adb->pquery("INSERT INTO vtiger_picklist (picklistid,name) VALUES(?,?)", array($new_picklistid, $this->name));
         self::log("Creating table {$picklist_table} ... DONE");
     } else {
         $new_picklistid = $adb->query_result($adb->pquery("SELECT picklistid FROM vtiger_picklist WHERE name=?", array($this->name)), 0, 'picklistid');
     }
     // Add value to picklist now
     $sortid = 0;
     // TODO To be set per role
     foreach ($values as $value) {
         $new_picklistvalueid = getUniquePicklistID();
         $presence = 1;
         // 0 - readonly, Refer function in include/ComboUtil.php
         $new_id = $adb->getUniqueID($picklist_table);
         $adb->pquery("INSERT INTO {$picklist_table}({$picklist_idcol}, {$this->name}, presence, picklist_valueid) VALUES(?,?,?,?)", array($new_id, $value, $presence, $new_picklistvalueid));
         ++$sortid;
         // Associate picklist values to all the role
         $adb->query("INSERT INTO vtiger_role2picklist(roleid, picklistvalueid, picklistid, sortid) SELECT roleid, \n\t\t\t\t{$new_picklistvalueid}, {$new_picklistid}, {$sortid} FROM vtiger_role");
     }
 }
开发者ID:hbsman,项目名称:vtigercrm-5.3.0-ja,代码行数:38,代码来源:Field.php

示例4: setPicklistValues

 /**
  * Set values for picklist field (for all the roles)
  * @param Array List of values to add.
  *
  * @internal Creates picklist base if it does not exists
  */
 function setPicklistValues($values)
 {
     global $adb, $default_charset;
     // Non-Role based picklist values
     if ($this->uitype == '16') {
         $this->setNoRolePicklistValues($values);
         return;
     }
     $picklist_table = 'vtiger_' . $this->name;
     $picklist_idcol = $this->name . 'id';
     if (!Vtiger_Utils::CheckTable($picklist_table)) {
         Vtiger_Utils::CreateTable($picklist_table, "({$picklist_idcol} INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t{$this->name} VARCHAR(200) NOT NULL,\n\t\t\t\tpresence INT (1) NOT NULL DEFAULT 1,\n\t\t\t\tpicklist_valueid INT NOT NULL DEFAULT 0,\n                sortorderid INT DEFAULT 0)", true);
         $new_picklistid = $this->__getPicklistUniqueId();
         $adb->pquery("INSERT INTO vtiger_picklist (picklistid,name) VALUES(?,?)", array($new_picklistid, $this->name));
         self::log("Creating table {$picklist_table} ... DONE");
     } else {
         $picklistResult = $adb->pquery("SELECT picklistid FROM vtiger_picklist WHERE name=?", array($this->name));
         $new_picklistid = $adb->query_result($picklistResult, 0, 'picklistid');
     }
     $specialNameSpacedPicklists = array('opportunity_type' => 'opptypeid', 'duration_minutes' => 'minutesid', 'recurringtype' => 'recurringeventid');
     // Fix Table ID column names
     $fieldName = (string) $this->name;
     if (in_array($fieldName . '_id', $adb->getColumnNames($picklist_table))) {
         $picklist_idcol = $fieldName . '_id';
     } elseif (array_key_exists($fieldName, $specialNameSpacedPicklists)) {
         $picklist_idcol = $specialNameSpacedPicklists[$fieldName];
     }
     // END
     // Add value to picklist now
     $picklistValues = self::getPicklistValues();
     $sortid = 0;
     // TODO To be set per role
     foreach ($values as $value) {
         if (in_array($value, $picklistValues)) {
             continue;
         }
         $new_picklistvalueid = getUniquePicklistID();
         $presence = 1;
         // 0 - readonly, Refer function in include/ComboUtil.php
         $new_id = $adb->getUniqueID($picklist_table);
         ++$sortid;
         $adb->pquery("INSERT INTO {$picklist_table}({$picklist_idcol}, {$this->name}, presence, picklist_valueid,sortorderid) VALUES(?,?,?,?,?)", array($new_id, $value, $presence, $new_picklistvalueid, $sortid));
         // Associate picklist values to all the role
         $adb->pquery("INSERT INTO vtiger_role2picklist(roleid, picklistvalueid, picklistid, sortid) SELECT roleid,\n\t\t\t\t{$new_picklistvalueid}, {$new_picklistid}, {$sortid} FROM vtiger_role", array());
     }
 }
开发者ID:yozhi,项目名称:YetiForceCRM,代码行数:52,代码来源:Field.php

示例5: return_module_language

                } else {
                    $temp_module_strings = return_module_language($current_language, $fld_module);
                }
                $mod_picklistvalue = trim($temp_module_strings[$picklistvalues]);
                if ($mod_picklistvalue == $pickArray[$i]) {
                    $pickArray[$i] = $picklistvalues;
                }
            }
            // End
            if ($pickArray[$i] == $picklistvalues) {
                $picklistcount++;
            }
        }
        if ($picklistcount == 0) {
            //Inserting a new pick list value to the corresponding picklist table
            $picklistvalue_id = getUniquePicklistID();
            $picklist_id = $adb->getUniqueID("vtiger_" . $tableName);
            $query = "insert into vtiger_" . $tableName . " values(?,?,?,?)";
            $params = array($picklist_id, $pickArray[$i], 1, $picklistvalue_id);
            $adb->pquery($query, $params);
        }
        $picklistcount = 0;
        $sql = "select picklist_valueid from vtiger_{$tableName} where {$tableName}=?";
        $pick_valueid = $adb->query_result($adb->pquery($sql, array($pickArray[$i])), 0, 'picklist_valueid');
        //To get the max sortid for the non editable picklist and the inserting by increasing the sortid for editable values....
        $sql = "select max(sortid)+1 as sortid from vtiger_role2picklist left join vtiger_{$tableName} on vtiger_{$tableName}.picklist_valueid=vtiger_role2picklist.picklistvalueid where roleid=? and picklistid=?  and presence=0";
        $sortid = $adb->query_result($adb->pquery($sql, array($roleid, $picklistid)), 0, 'sortid');
        $sql = "insert into vtiger_role2picklist values(?,?,?,?)";
        $adb->pquery($sql, array($roleid, $pick_valueid, $picklistid, $sortid));
    }
}
开发者ID:hbsman,项目名称:vtigercrm-5.3.0-ja,代码行数:31,代码来源:UpdateComboValues.php

示例6: addCustomField


//.........这里部分代码省略.........
            //adodb type
            $uichekdata = 'V~O';
        } elseif ($fldType == 'Checkbox') {
            $uitype = 56;
            $type = "C(3) default 0";
            //adodb type
            $uichekdata = 'C~O';
        } elseif ($fldType == 'TextArea') {
            $uitype = 21;
            $type = "X";
            //adodb type
            $uichekdata = 'V~O';
        } elseif ($fldType == 'MultiSelectCombo') {
            $uitype = 33;
            $type = "X";
            //adodb type
            $uichekdata = 'V~O';
        } elseif ($fldType == 'Skype') {
            $uitype = 85;
            $type = "C(255) default () ";
            //adodb type
            $uichekdata = 'V~O';
        }
        if (is_numeric($blockid)) {
            if ($_REQUEST['fieldid'] == '') {
                $max_fieldsequence = "select max(sequence) as maxsequence from vtiger_field where block = ? ";
                $res = $adb->pquery($max_fieldsequence, array($blockid));
                $max_seq = $adb->query_result($res, 0, 'maxsequence');
                if ($fldmodule == 'Quotes' || $fldmodule == 'PurchaseOrder' || $fldmodule == 'SalesOrder' || $fldmodule == 'Invoice') {
                    $quickcreate = 3;
                } else {
                    $quickcreate = 1;
                }
                $query = "insert into vtiger_field (tabid,fieldid,columnname,tablename,generatedtype,uitype,fieldname,fieldlabel,readonly,presence,defaultvalue,maximumlength,sequence,block,displaytype,typeofdata,quickcreate,quickcreatesequence,info_type,masseditable) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                $qparams = array($tabid, $custfld_fieldid, $columnName, $tableName, 2, $uitype, $columnName, $fldlabel, 0, 2, '', 100, $max_seq + 1, $blockid, 1, $uichekdata, $quickcreate, 0, 'BAS', 1);
                $adb->pquery($query, $qparams);
                $adb->alterTable($tableName, $columnName . " " . $type, "Add_Column");
                //Inserting values into vtiger_profile2field vtiger_tables
                $sql1 = "select * from vtiger_profile";
                $sql1_result = $adb->pquery($sql1, array());
                $sql1_num = $adb->num_rows($sql1_result);
                for ($i = 0; $i < $sql1_num; $i++) {
                    $profileid = $adb->query_result($sql1_result, $i, "profileid");
                    $sql2 = "insert into vtiger_profile2field values(?,?,?,?,?)";
                    $adb->pquery($sql2, array($profileid, $tabid, $custfld_fieldid, 0, 0));
                }
                //Inserting values into def_org vtiger_tables
                $sql_def = "insert into vtiger_def_org_field values(?,?,?,?)";
                $adb->pquery($sql_def, array($tabid, $custfld_fieldid, 0, 0));
                if ($fldType == 'Picklist' || $fldType == 'MultiSelectCombo') {
                    $columnName = $adb->sql_escape_string($columnName);
                    // Creating the PickList Table and Populating Values
                    if ($_REQUEST['fieldid'] == '') {
                        $qur = "CREATE TABLE vtiger_" . $columnName . " (\n\t\t\t\t\t\t\t" . $columnName . "id int(19) NOT NULL auto_increment,\n\t\t\t\t\t\t\t" . $columnName . " varchar(200) NOT NULL,\n\t\t\t\t\t\t\tpresence int(1) NOT NULL default '1',\n\t\t\t\t\t\t\tpicklist_valueid int(19) NOT NULL default '0',\n\t\t\t\t\t\t\tPRIMARY KEY  (" . $columnName . "id)\n\t\t\t\t\t\t)";
                        $adb->pquery($qur, array());
                    }
                    //Adding a  new picklist value in the picklist table
                    if ($mode != 'edit') {
                        $picklistid = $adb->getUniqueID("vtiger_picklist");
                        $sql = "insert into vtiger_picklist values(?,?)";
                        $adb->pquery($sql, array($picklistid, $columnName));
                    }
                    $roleid = $current_user->roleid;
                    $qry = "select picklistid from vtiger_picklist where  name=?";
                    $picklistid = $adb->query_result($adb->pquery($qry, array($columnName)), 0, 'picklistid');
                    $pickArray = array();
                    $fldPickList = vtlib_purify($_REQUEST['fldPickList']);
                    $pickArray = explode("\n", $fldPickList);
                    $count = count($pickArray);
                    global $default_charset;
                    for ($i = 0; $i < $count; $i++) {
                        $pickArray[$i] = trim(htmlentities($pickArray[$i], ENT_QUOTES, $default_charset));
                        if ($pickArray[$i] != '') {
                            $picklistcount = 0;
                            $sql = "select {$columnName} from vtiger_{$columnName}";
                            $numrow = $adb->num_rows($adb->pquery($sql, array()));
                            for ($x = 0; $x < $numrow; $x++) {
                                $picklistvalues = $adb->query_result($adb->pquery($sql, array()), $x, $columnName);
                                if ($pickArray[$i] == $picklistvalues) {
                                    $picklistcount++;
                                }
                            }
                            if ($picklistcount == 0) {
                                $picklist_valueid = getUniquePicklistID();
                                $query = "insert into vtiger_" . $columnName . " values(?,?,?,?)";
                                $adb->pquery($query, array($adb->getUniqueID("vtiger_" . $columnName), $pickArray[$i], 1, $picklist_valueid));
                                /*$sql="update vtiger_picklistvalues_seq set id = ?";
                                		$adb->pquery($sql, array(++$picklist_valueid));*/
                            }
                            $sql = "select picklist_valueid from vtiger_{$columnName} where {$columnName}=?";
                            $pick_valueid = $adb->query_result($adb->pquery($sql, array($pickArray[$i])), 0, 'picklist_valueid');
                            $sql = "insert into vtiger_role2picklist select roleid,{$pick_valueid},{$picklistid},{$i} from vtiger_role";
                            $adb->pquery($sql, array());
                        }
                    }
                }
            }
        }
    }
}
开发者ID:mslokhat,项目名称:corebos,代码行数:101,代码来源:LayoutBlockList.php

示例7: explode

     $pickArray = explode("\n", $fldPickList);
     $count = count($pickArray);
     for ($i = 0; $i < $count; $i++) {
         $pickArray[$i] = trim(from_html($pickArray[$i]));
         if ($pickArray[$i] != '') {
             $picklistcount = 0;
             $sql = "select {$columnName} from vtiger_{$columnName}";
             $numrow = $adb->num_rows($adb->pquery($sql, array()));
             for ($x = 0; $x < $numrow; $x++) {
                 $picklistvalues = $adb->query_result($adb->pquery($sql, array()), $x, $columnName);
                 if ($pickArray[$i] == $picklistvalues) {
                     $picklistcount++;
                 }
             }
             if ($picklistcount == 0) {
                 $picklist_valueid = getUniquePicklistID();
                 $query = "insert into vtiger_" . $columnName . " values(?,?,?,?)";
                 $adb->pquery($query, array($adb->getUniqueID("vtiger_" . $columnName), $pickArray[$i], 1, $picklist_valueid));
                 /*$sql="update vtiger_picklistvalues_seq set id = ?";
                 		$adb->pquery($sql, array(++$picklist_valueid));*/
             }
             $sql = "select picklist_valueid from vtiger_{$columnName} where {$columnName}=?";
             $pick_valueid = $adb->query_result($adb->pquery($sql, array($pickArray[$i])), 0, 'picklist_valueid');
             $sql = "insert into vtiger_role2picklist select roleid,{$pick_valueid},{$picklistid},{$i} from vtiger_role";
             $adb->pquery($sql, array());
         }
     }
 }
 //Inserting into LeadMapping table - Jaguar
 if ($fldmodule == 'Leads' && $_REQUEST['fieldid'] == '') {
     $sql_def = "insert into vtiger_convertleadmapping (leadfid) values(?)";
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:31,代码来源:AddCustomFieldToDB.php

示例8: array_unique

        //Remove the repeated entries and make this array with unique entries
        $csv_picklist_values[$fieldname] = array_unique($csv_picklist_values[$fieldname]);
    }
}
//Now we have to add the CSV picklists in the picklist table if it is not exist
foreach ($csv_picklist_values as $fieldname => $temp_array) {
    $tablename = "vtiger_{$fieldname}";
    foreach ($temp_array as $ind => $picklist_value) {
        $pick_val = strtolower($picklist_value);
        //Check whether $picklist_value is exist in the array of available picklist entries
        if (!in_array($pick_val, $converted_table_picklist_values[$fieldname])) {
            //Not exist, so we have to add this $picklist_value in $fieldname(picklist name) table
            $picklist_value = addslashes($picklist_value);
            $adb->println("{$picklist_value} has to be added in the table {$tablename}");
            $cfId = $adb->getUniqueID($tablename);
            $unique_picklist_value = getUniquePicklistID();
            $qry = "insert into {$tablename} values(?,?,?,?)";
            $adb->pquery($qry, array($cfId, $picklist_value, 1, $unique_picklist_value));
            //added to fix ticket#4492
            $picklistId_qry = "select picklistid from vtiger_picklist where name=?";
            $picklistId_res = $adb->pquery($picklistId_qry, array($fieldname));
            $picklist_Id = $adb->query_result($picklistId_res, 0, 'picklistid');
            $role_id = $current_user->roleid;
            $sort_qry = "select max(sortid)+1 as sortid from vtiger_role2picklist where picklistid=? and roleid=?";
            $sort_qry_res = $adb->pquery($sort_qry, array($picklist_Id, $role_id));
            $sort_id = $adb->query_result($sort_qry_res, 0, 'sortid');
            $role_picklist = "insert into vtiger_role2picklist values (?,?,?,?)";
            $adb->pquery($role_picklist, array($role_id, $unique_picklist_value, $picklist_Id, $sort_id));
        }
    }
}
开发者ID:hbsman,项目名称:vtigercrm-5.3.0-ja,代码行数:31,代码来源:picklist_addition.php

示例9: insert_values

function insert_values($picklist, $picklistid)
{
    global $adb;
    $result = $adb->query("select * from vtiger_{$picklist}");
    $numrow = $adb->num_rows($result);
    for ($i = 0; $i < $numrow; $i++) {
        $picklist_name = decode_html($adb->query_result($result, $i, $picklist));
        $picklist_valueid = getUniquePicklistID();
        $picklistquery = "update vtiger_{$picklist} set picklist_valueid=? where {$picklist}=?";
        $adb->pquery($picklistquery, array($picklist_valueid, $picklist_name));
        $sql = "select roleid from vtiger_role";
        $role_result = $adb->query($sql);
        $numrows = $adb->num_rows($role_result);
        for ($k = 0; $k < $numrows; $k++) {
            $roleid = $adb->query_result($role_result, $k, 'roleid');
            $adb->query("insert into vtiger_role2picklist values('" . $roleid . "'," . $picklist_valueid . ",{$picklistid}," . $i . ")");
        }
    }
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:19,代码来源:503_to_504rc.php

示例10: getInsertValues


//.........这里部分代码省略.........
            $log->debug("Lead's custom vtiger_field value is " . $lead_value);
        }
        //Query for getting the column name for Accounts/Contacts/Potentials if custom vtiger_field for lead is mappped
        $sql_type = "select vtiger_field.fieldid,vtiger_field.uitype,vtiger_field.columnname from vtiger_field,vtiger_tab where vtiger_field.tabid=vtiger_tab.tabid and generatedtype=2 and vtiger_field.presence in (0,2) and vtiger_tab.name=";
        $params = array();
        if ($type == "Accounts") {
            if ($account_id_val != "" && $account_id_val != 0) {
                $flag = "true";
                $log->info("Getting the  Accounts custom vtiger_field column name  ");
                $sql_type .= "'Accounts' and fieldid=?";
                array_push($params, $account_id_val);
            }
        } else {
            if ($type == "Contacts") {
                if ($contact_id_val != "" && $contact_id_val != 0) {
                    $flag = "true";
                    $log->info("Getting the  Contacts custom vtiger_field column name  ");
                    $sql_type .= "'Contacts' and fieldid=?";
                    array_push($params, $contact_id_val);
                }
            } else {
                if ($type == "Potentials") {
                    if ($potential_id_val != "" && $potential_id_val != 0) {
                        $flag = "true";
                        $log->info("Getting the  Potentials custom vtiger_field column name  ");
                        $sql_type .= "'Potentials' and fieldid=?";
                        array_push($params, $potential_id_val);
                    }
                }
            }
        }
        if ($flag == "true") {
            $type_result = $adb->pquery($sql_type, $params);
            //To construct the cf array
            $colname = $adb->query_result($type_result, 0, "columnname");
            $type_insert_column[] = $colname;
            $type_uitype = $adb->query_result($type_result, 0, "uitype");
            //To construct the cf array
            $ins_val = $adb->query_result($lead_val_result, 0, $lead_column_name);
            //This array is used to store the tablename as the key and the value for that table in the custom field of the uitype only for 15 and 33(Multiselect cf)...
            if ($lead_uitype == 33 || $lead_uitype == 15) {
                $lead_val_arr[$colname] = $lead_column_name;
                $value_cf_array[$colname] = $ins_val;
            }
            $insert_value[] = $ins_val;
        }
    }
    if (count($value_cf_array) > 0) {
        if (count($type_insert_column) > 0) {
            foreach ($value_cf_array as $key => $value) {
                $tableName = $key;
                $tableVal = $value;
                if ($tableVal != '') {
                    $tab_val = explode("|##|", $value);
                    if (count($tab_val) > 0) {
                        for ($k = 0; $k < count($tab_val); $k++) {
                            $val = $tab_val[$k];
                            $sql = "select {$tableName} from vtiger_{$tableName}";
                            $numRow = $adb->num_rows($adb->query($sql));
                            $count = 0;
                            for ($n = 0; $n < $numRow; $n++) {
                                $exist_val = $adb->query_result($adb->query($sql), $n, $tableName);
                                if (trim($exist_val) == trim($val)) {
                                    $count++;
                                }
                            }
                            if ($count == 0) {
                                $cfId = $adb->getUniqueID("vtiger_{$tableName}");
                                $unique_picklist_value = getUniquePicklistID();
                                $qry = "insert into vtiger_{$tableName} values(?,?,?,?)";
                                $adb->pquery($qry, array($cfId, trim($val), 1, $unique_picklist_value));
                                //added to fix ticket#4492
                                $picklistId_qry = "select picklistid from vtiger_picklist where name=?";
                                $picklistId_res = $adb->pquery($picklistId_qry, array($tableName));
                                $picklist_Id = $adb->query_result($picklistId_res, 0, 'picklistid');
                                //While adding a new value into the picklist table, the roleid's which has permission for the lead cf will only given permission for contacts,potentials and account module while converting. -- refer ticket #4885 ---
                                $role_qry = "select roleid from vtiger_role2picklist where picklistvalueid in (select picklist_valueid from vtiger_" . $lead_val_arr[$tableName] . "  where " . $lead_val_arr[$tableName] . "='" . trim($val) . "')";
                                $numOFRole = $adb->num_rows($adb->query($role_qry));
                                for ($l = 0; $l < $numOFRole; $l++) {
                                    $role_id = $adb->query_result($adb->query($role_qry), $l, 'roleid');
                                    $sort_qry = "select max(sortid)+1 as sortid from vtiger_role2picklist where picklistid=? and roleid=?";
                                    $sort_qry_res = $adb->pquery($sort_qry, array($picklist_Id, $role_id));
                                    $sort_id = $adb->query_result($sort_qry_res, 0, 'sortid');
                                    $role_picklist = "insert into vtiger_role2picklist values (?,?,?,?)";
                                    $adb->pquery($role_picklist, array($role_id, $unique_picklist_value, $picklist_Id, $sort_id));
                                }
                                //end
                            }
                        }
                    }
                }
            }
        }
    }
    $log->debug("columns to be inserted are " . $type_insert_column);
    $log->debug("columns to be inserted are " . $insert_value);
    $values = array('columns' => $type_insert_column, 'values' => $insert_value);
    $log->debug("Exiting getInsertValues method ...");
    return $values;
}
开发者ID:vtiger-jp,项目名称:vtigercrm-5.1.x-ja,代码行数:101,代码来源:LeadConvertToEntities.php


注:本文中的getUniquePicklistID函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。