Exemplo n.º 1
0
/**
 * Function to get customfield entries
 * @param string $module - Module name
 * return array  $cflist - customfield entries
 */
function getFieldListEntries($module)
{
    $tabid = getTabid($module);
    global $adb, $smarty, $log, $current_user;
    global $theme;
    $theme_path = "themes/" . $theme . "/";
    $image_path = "themes/images/";
    $dbQuery = "select vtiger_blocks.*,vtiger_tab.presence as tabpresence  from vtiger_blocks" . " inner join vtiger_tab on vtiger_tab.tabid = vtiger_blocks.tabid" . " where vtiger_blocks.tabid=?  and vtiger_tab.presence = 0 order by sequence";
    $result = $adb->pquery($dbQuery, array($tabid));
    $row = $adb->fetch_array($result);
    $focus = CRMEntity::getInstance($module);
    $nonEditableUiTypes = array('4', '70');
    // To get reference field names
    require_once 'include/Webservices/Utils.php';
    $handler = vtws_getModuleHandlerFromName($module, $current_user);
    $meta = $handler->getMeta();
    $referenceFieldNames = array_keys($meta->getReferenceFieldDetails());
    $cflist = array();
    $i = 0;
    if ($row != '') {
        do {
            if ($row["blocklabel"] == 'LBL_CUSTOM_INFORMATION') {
                $smarty->assign("CUSTOMSECTIONID", $row["blockid"]);
            }
            if ($row["blocklabel"] == 'LBL_RELATED_PRODUCTS') {
                $smarty->assign("RELPRODUCTSECTIONID", $row["blockid"]);
            }
            if ($row["blocklabel"] == 'LBL_COMMENTS' || $row['blocklabel'] == 'LBL_COMMENT_INFORMATION') {
                $smarty->assign("COMMENTSECTIONID", $row["blockid"]);
            }
            if ($row['blocklabel'] == 'LBL_TICKET_RESOLUTION') {
                $smarty->assign("SOLUTIONBLOCKID", $row["blockid"]);
            }
            if ($row['blocklabel'] == '') {
                continue;
            }
            $cflist[$i]['tabpresence'] = $row['tabpresence'];
            $cflist[$i]['module'] = $module;
            $cflist[$i]['blocklabel'] = getTranslatedString($row["blocklabel"], $module);
            $cflist[$i]['blockid'] = $row["blockid"];
            $cflist[$i]['display_status'] = $row["display_status"];
            $cflist[$i]['tabid'] = $tabid;
            $cflist[$i]['blockselect'] = $row["blockid"];
            $cflist[$i]['sequence'] = $row["sequence"];
            $cflist[$i]['iscustom'] = $row["iscustom"];
            if ($module != 'Invoices' && $module != 'Quotes' && $module != 'SalesOrder' && $module != 'Invoice') {
                $sql_field = "select * from  vtiger_field where block=? and vtiger_field.displaytype IN (1,2,4) order by sequence";
                $sql_field_params = array($row["blockid"]);
            } else {
                $sql_field = "select * from  vtiger_field where block=? and (vtiger_field.fieldlabel!='Total' and vtiger_field.fieldlabel!='Sub Total' and vtiger_field.fieldlabel!='Tax') and vtiger_field.displaytype IN (1,2,4) order by sequence";
                $sql_field_params = array($row["blockid"]);
            }
            $result_field = $adb->pquery($sql_field, $sql_field_params);
            $row_field = $adb->fetch_array($result_field);
            if ($row_field != '') {
                $cf_element = array();
                $cf_hidden_element = array();
                $count = 0;
                $hiddencount = 0;
                do {
                    $fieldid = $row_field['fieldid'];
                    $presence = $row_field['presence'];
                    $fieldname = $row_field['fieldname'];
                    $customfieldflag = InStrCount($row_field['fieldname'], 'cf_', true);
                    $quickcreate = $row_field['quickcreate'];
                    $massedit = $row_field['masseditable'];
                    $typeofdata = $row_field['typeofdata'];
                    $displaytype = $row_field['displaytype'];
                    $uitype = $row_field['uitype'];
                    $fld_type_name = getCustomFieldTypeName($row_field['uitype']);
                    $defaultValue = $row_field['defaultvalue'];
                    if (!empty($defaultValue) && ($uitype == '5' || $uitype == '6' || $uitype == '23')) {
                        $defaultValue = getValidDisplayDate($defaultValue);
                    }
                    $fieldlabel = getTranslatedString($row_field['fieldlabel'], $module);
                    $defaultPermitted = true;
                    $strictlyMandatory = false;
                    if (isset($focus->mandatory_fields) && !empty($focus->mandatory_fields) && in_array($fieldname, $focus->mandatory_fields)) {
                        $strictlyMandatory = true;
                        $defaultPermitted = false;
                    } elseif (in_array($uitype, $nonEditableUiTypes) || $displaytype == 2) {
                        $strictlyMandatory = true;
                        $defaultPermitted = false;
                    }
                    if (in_array($fieldname, $referenceFieldNames)) {
                        $defaultPermitted = false;
                    }
                    $visibility = getFieldInfo($fieldname, $typeofdata, $quickcreate, $massedit, $presence, $strictlyMandatory, $customfieldflag, $displaytype, $uitype);
                    $allValues = array();
                    if (in_array($uitype, array('15', '16', '33'))) {
                        $allValues = getAllPickListValues($fieldname);
                    }
                    if ($presence == 0 || $presence == 2) {
                        $cf_element[$count]['fieldselect'] = $fieldid;
                        $cf_element[$count]['blockid'] = $row['blockid'];
                        $cf_element[$count]['tabid'] = $tabid;
                        $cf_element[$count]['no'] = $count;
                        $cf_element[$count]['label'] = $fieldlabel;
                        $cf_element[$count]['fieldlabel'] = $row_field['fieldlabel'];
                        $cf_element[$count]['type'] = $fld_type_name;
                        $cf_element[$count]['typeofdata'] = $typeofdata;
                        $cf_element[$count]['uitype'] = $uitype;
                        $cf_element[$count]['columnname'] = $row_field['columnname'];
                        $cf_element[$count]['defaultvalue'] = array('permitted' => $defaultPermitted, 'value' => $defaultValue, '_allvalues' => $allValues);
                        $cf_element[$count] = array_merge($cf_element[$count], $visibility);
                        $count++;
                    } else {
                        $cf_hidden_element[$hiddencount]['fieldselect'] = $fieldid;
                        $cf_hidden_element[$hiddencount]['blockid'] = $row['blockid'];
                        $cf_hidden_element[$hiddencount]['tabid'] = $tabid;
                        $cf_hidden_element[$hiddencount]['no'] = $hiddencount;
                        $cf_hidden_element[$hiddencount]['label'] = $fieldlabel;
                        $cf_hidden_element[$hiddencount]['fieldlabel'] = $row_field['fieldlabel'];
                        $cf_hidden_element[$hiddencount]['type'] = $fld_type_name;
                        $cf_hidden_element[$hiddencount]['typeofdata'] = $typeofdata;
                        $cf_hidden_element[$hiddencount]['uitype'] = $uitype;
                        $cf_hidden_element[$hiddencount]['columnname'] = $row_field['columnname'];
                        $cf_hidden_element[$hiddencount]['defaultvalue'] = array('permitted' => $defaultPermitted, 'value' => $defaultValue, '_allvalues' => $allValues);
                        $cf_hidden_element[$hiddencount] = array_merge($cf_hidden_element[$hiddencount], $visibility);
                        $hiddencount++;
                    }
                } while ($row_field = $adb->fetch_array($result_field));
                $cflist[$i]['no'] = $count;
                $cflist[$i]['hidden_count'] = $hiddencount;
            } else {
                $cflist[$i]['no'] = 0;
            }
            $query_fields_not_in_block = 'select fieldid,fieldlabel,block from vtiger_field ' . 'inner join vtiger_blocks on vtiger_field.block=vtiger_blocks.blockid ' . 'where vtiger_field.block != ? and vtiger_blocks.blocklabel not in ("LBL_TICKET_RESOLUTION","LBL_COMMENTS","LBL_COMMENT_INFORMATION") ' . 'AND vtiger_field.tabid = ? and vtiger_field.displaytype IN (1,2,4) order by vtiger_field.sequence';
            $params = array($row['blockid'], $tabid);
            $fields = $adb->pquery($query_fields_not_in_block, $params);
            $row_field = $adb->fetch_array($fields);
            if ($row_field != '') {
                $movefields = array();
                $movefieldcount = 0;
                do {
                    $movefields[$movefieldcount]['fieldid'] = $row_field['fieldid'];
                    $movefields[$movefieldcount]['fieldlabel'] = getTranslatedString($row_field['fieldlabel'], $module);
                    $movefieldcount++;
                } while ($row_field = $adb->fetch_array($fields));
                $cflist[$i]['movefieldcount'] = $movefieldcount;
            } else {
                $cflist[$i]['movefieldcount'] = 0;
            }
            $cflist[$i]['field'] = $cf_element;
            $cflist[$i]['hiddenfield'] = $cf_hidden_element;
            $cflist[$i]['movefield'] = $movefields;
            $cflist[$i]['hascustomtable'] = $focus->customFieldTable;
            unset($cf_element);
            unset($cf_hidden_element);
            unset($movefields);
            $i++;
        } while ($row = $adb->fetch_array($result));
    }
    return $cflist;
}
Exemplo n.º 2
0
/**
*   Searches all the fields of any table for a keyword by matching any text or number within a value
*/
function searchRows($tableName, $keyword, $db)
{
    if ($tableName == "" || $keyword == "") {
        Errors::report("Values are missing: Table name: {$tableName}, keyword: {$keyword}.");
        return false;
    }
    $fieldinfo = getFieldInfo($tableName, $db);
    if ($fieldinfo === false) {
        return false;
    }
    if (is_string($fieldinfo)) {
        return $fieldinfo;
    }
    $i = 0;
    $q = "select * from {$tableName} where ";
    foreach ($fieldinfo as $f) {
        if ($i > 0) {
            $q .= " or ";
        }
        $field = $f['Field'];
        $q .= $field . " LIKE '%" . $keyword . "%' ";
        $i++;
    }
    $qr = $db->executeQuery($q);
    if ($qr === false) {
        Errors::report($db->err);
        return false;
    }
    if (count($qr) == 0) {
        return "No results were found for search keyword = {$keyword} in table {$tableName}.";
    }
    return $qr;
}
Exemplo n.º 3
0
*/
if (!isset($_POST['submit'])) {
    echo "You can not access this page directly.";
    return;
}
require_once 'config/project.class.php';
$al = new Project();
$title = "";
$body = "";
$rep = "";
$islogin = false;
$mail_sent = false;
$isinserted = false;
extract($_POST);
list($month, $day, $year) = explode("/", $_POST['birthdate']);
$fieldinfo = getFieldInfo('users', $al->db);
$i = 0;
foreach ($fieldinfo as $f) {
    if ($i > 0) {
        $q .= " or ";
    }
    $fields[] = $f['Field'];
    $i++;
}
$values = array("NULL", trim($email), trim($password), trim($fname), trim($lname), $sex, $year . "-" . $month . "-" . $day, sha1(rand(10, 100)), 0, 1, 0, date("Y-m-d G:i:s"), date("Y-m-d G:i:s"), 0);
$isinserted = setRow('users', $fields, $values, 'insert', $al->db);
if ($isinserted === true) {
    $title = "Congratulations!";
    $body = "You are now registered to Articulatelogic CMS. You can now login, with your user name and password that you provided.";
    $rep = "Signup Successful !";
} else {
Exemplo n.º 4
0
    $email = $l->getEmail();
    $utype = $l->utype;
}
$al->tp->assign('islogin', $islogin);
$al->tp->assign('email', $email);
if ($utype != 1) {
    Errors::report("You do not have permission to view this page.");
    return;
}
extract($_POST);
if ($action == "add") {
    $id = getNewId("articles", $al->db);
    if ($id == false) {
        return;
    }
    $fieldinfo = getFieldInfo('articles', $al->db);
    if (is_string($fieldinfo)) {
        $rep .= $fieldinfo;
    }
    if ($fieldinfo === false) {
        return;
    }
    $i = 0;
    foreach ($fieldinfo as $f) {
        if ($i > 0) {
            $q .= " or ";
        }
        $fields[] = $f['Field'];
        $i++;
    }
    $values = array($id, $l->getId(), $cat, addslashes($arturl), addslashes($arttitle), addslashes($subtitle), addslashes(htmlentities($bodytxt)), addslashes($remarks), addslashes($keywords), 0, 0, date("Y-m-d H:i:s"), date("Y-m-d H:i:s"), 0);
Exemplo n.º 5
0
    $email = $l->getEmail();
    $utype = $l->utype;
}
$al->tp->assign('islogin', $islogin);
$al->tp->assign('email', $email);
if ($utype != 1) {
    Errors::report("You do not have permission to view this page.");
    return;
}
extract($_POST);
if ($action == "add") {
    $id = getNewId("categories", $al->db);
    if ($id == false) {
        return;
    }
    $fieldinfo = getFieldInfo('categories', $al->db);
    if (is_string($fieldinfo)) {
        $rep .= $fieldinfo;
    }
    if ($fieldinfo === false) {
        return;
    }
    $i = 0;
    foreach ($fieldinfo as $f) {
        if ($i > 0) {
            $q .= " or ";
        }
        $fields[] = $f['Field'];
        $i++;
    }
    $values = array($id, addslashes(trim($cname)), $mtype, date("Y-m-d H:i:s"), date("Y-m-d H:i:s"), 0);