diff --git a/oss/vtiger/trunk/modules/Users/AddMailAccount.php b/oss/vtiger/trunk/modules/Users/AddMailAccount.php new file mode 100644 index 00000000..ad404c0f --- /dev/null +++ b/oss/vtiger/trunk/modules/Users/AddMailAccount.php @@ -0,0 +1,115 @@ +assign("MOD", $mod_strings); +$smarty->assign("APP", $app_strings); +$smarty->assign("THEME", $theme); +$smarty->assign("IMAGE_PATH", $image_path); + +if(isset($_REQUEST['record']) && $_REQUEST['record']!='') +{ + $sql = "select * from vtiger_mail_accounts where user_id=?"; + $result = $adb->pquery($sql, array($_REQUEST['record'])); + $rowcount = $adb->num_rows($result); + + if ($rowcount!=0) + { + while($temprow = $adb->fetchByAssoc($result)) + { + $smarty->assign("DISPLAYNAME", $temprow['display_name']); + $smarty->assign("ID", $temprow['user_id']); + $smarty->assign("EMAIL", $temprow['mail_id']); + $smarty->assign("ACCOUNTNAME", $temprow['account_name']); + $smarty->assign($temprow['mail_protocol'],$temprow['mail_protocol']); + $smarty->assign("SERVERUSERNAME", $temprow['mail_username']); + $smarty->assign("SERVERPASSWORD", $temprow['mail_password']); + $smarty->assign("SERVERNAME", $temprow['mail_servername']); + $smarty->assign("RECORD_ID", $temprow['account_id']); + $smarty->assign("BOX_REFRESH", $temprow['box_refresh']); + $smarty->assign("MAILS_PER_PAGE", $temprow['mails_per_page']); + $smarty->assign("EDIT", "TRUE"); + + if(strtolower($temprow['mail_protocol']) == "imap") + $smarty->assign("IMAP", "CHECKED"); + if(strtolower($temprow['mail_protocol']) == "imap2") + $smarty->assign("IMAP2", "CHECKED"); + if(strtolower($temprow['mail_protocol']) == "imap4") + $smarty->assign("IMAP4", "CHECKED"); + if(strtolower($temprow['mail_protocol']) == "imap4rev1") + $smarty->assign("IMAP4R1", "CHECKED"); + if(strtolower($temprow['mail_protocol']) == "pop3") + $smarty->assign("POP3", "CHECKED"); + + if(strtolower($temprow['ssltype']) == "notls") + $smarty->assign("NOTLS", "CHECKED"); + if(strtolower($temprow['ssltype']) == "tls") + $smarty->assign("TLS", "CHECKED"); + if(strtolower($temprow['ssltype']) == "ssl") + $smarty->assign("SSL", "CHECKED"); + if(strtolower($temprow['sslmeth']) == "validate-cert") + $smarty->assign("VALIDATECERT", "CHECKED"); + if(strtolower($temprow['sslmeth']) == "novalidate-cert") + $smarty->assign("NOVALIDATECERT", "CHECKED"); + + if($temprow['int_mailer'] == "1") + $smarty->assign("INT_MAILER_USE", "CHECKED"); + else + $smarty->assign("INT_MAILER_NOUSE", "CHECKED"); + if(strtolower($temprow['box_refresh']) == "60000") + $smarty->assign("BOX_OPT1", " SELECTED"); + if(strtolower($temprow['box_refresh']) == "120000") + $smarty->assign("BOX_OPT2", " SELECTED"); + if(strtolower($temprow['box_refresh']) == "180000") + $smarty->assign("BOX_OPT3", " SELECTED"); + if(strtolower($temprow['box_refresh']) == "240000") + $smarty->assign("BOX_OPT4", " SELECTED"); + if(strtolower($temprow['box_refresh']) == "300000") + $smarty->assign("BOX_OPT5", " SELECTED"); + } + } +} +$qry_res = $adb->pquery("select * from vtiger_mail_accounts where user_id=?", array($current_user->id)); +$count = $adb->num_rows($qry_res); +if($count > 0) + $field = '';//""; +else + $field = ''; +$smarty->assign('CHANGE_PW_BUTTON',$field); + +$return_module = vtlib_purify($_REQUEST['return_module']); +if(empty($return_module)) $return_module = 'Settings'; +else $return_module = htmlspecialchars($return_module, ENT_QUOTES, $default_charset); + +$return_action = vtlib_purify($_REQUEST['return_action']); +if(empty($return_action)) $return_action = 'index'; +else $return_action = htmlspecialchars($return_action, ENT_QUOTES, $default_charset); + +$smarty->assign("RETURN_MODULE",$return_module); +$smarty->assign("RETURN_ACTION",$return_action); +$smarty->assign("JAVASCRIPT", get_validate_record_js()); +$smarty->assign("USERID", $current_user->id); + +$smarty->display('AddMailAccount.tpl'); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Users/Announcements.php b/oss/vtiger/trunk/modules/Users/Announcements.php new file mode 100644 index 00000000..59aeb2ee --- /dev/null +++ b/oss/vtiger/trunk/modules/Users/Announcements.php @@ -0,0 +1,36 @@ +pquery($query, array($current_user->id)); +$announcement=$adb->query_result($result,0,'announcement'); +$title_prev=$adb->query_result($result,0,'title'); +$id=$adb->query_result($result,0,'creatorid'); + +$smarty = new vtigerCRM_Smarty; + +$smarty->assign("ANNOUNCE",$announcement); +$smarty->assign("MOD", return_module_language($current_language,'Settings')); +$smarty->assign("THEME", $theme); +$smarty->assign("IMAGE_PATH",$image_path); +$smarty->assign("APP", $app_strings); +$smarty->assign("CMOD", $mod_strings); + +$smarty->display("Settings/Announcements.tpl"); + +?> diff --git a/oss/vtiger/trunk/modules/Users/Authenticate.php b/oss/vtiger/trunk/modules/Users/Authenticate.php new file mode 100644 index 00000000..b765218f --- /dev/null +++ b/oss/vtiger/trunk/modules/Users/Authenticate.php @@ -0,0 +1,155 @@ +column_fields["user_name"] = to_html($_REQUEST['user_name']); +$user_password = vtlib_purify($_REQUEST['user_password']); + +$focus->load_user($user_password); + +if($focus->is_authenticated()) +{ + + //Inserting entries for audit trail during login + + if($audit_trail == 'true') + { + if($record == '') + $auditrecord = ''; + else + $auditrecord = $record; + + $date_var = $adb->formatDate(date('Y-m-d H:i:s'), true); + $query = "insert into vtiger_audit_trial values(?,?,?,?,?,?)"; + $params = array($adb->getUniqueID('vtiger_audit_trial'), $focus->id, 'Users','Authenticate','',$date_var); + $adb->pquery($query, $params); + } + + + // Recording the login info + $usip=$_SERVER['REMOTE_ADDR']; + $intime=date("Y/m/d H:i:s"); + require_once('modules/Users/LoginHistory.php'); + $loghistory=new LoginHistory(); + $Signin = $loghistory->user_login($focus->column_fields["user_name"],$usip,$intime); + + //Security related entries start + require_once('include/utils/UserInfoUtil.php'); + + createUserPrivilegesfile($focus->id); + + //Security related entries end + session_unregister('login_password'); + session_unregister('login_error'); + session_unregister('login_user_name'); + + $_SESSION['authenticated_user_id'] = $focus->id; + $_SESSION['app_unique_key'] = $application_unique_key; + + // store the user's theme in the session + if (isset($_REQUEST['login_theme'])) { + $authenticated_user_theme = vtlib_purify($_REQUEST['login_theme']); + } + elseif (isset($_REQUEST['ck_login_theme'])) { + $authenticated_user_theme = vtlib_purify($_REQUEST['ck_login_theme']); + } + else { + $authenticated_user_theme = $default_theme; + } + + // store the user's language in the session + if (isset($_REQUEST['login_language'])) { + $authenticated_user_language = vtlib_purify($_REQUEST['login_language']); + } + elseif (isset($_REQUEST['ck_login_language'])) { + $authenticated_user_language = vtlib_purify($_REQUEST['ck_login_language']); + } + else { + $authenticated_user_language = $default_language; + } + + // If this is the default user and the default user theme is set to reset, reset it to the default theme value on each login + if($reset_theme_on_default_user && $focus->user_name == $default_user_name) + { + $authenticated_user_theme = $default_theme; + } + if(isset($reset_language_on_default_user) && $reset_language_on_default_user && $focus->user_name == $default_user_name) + { + $authenticated_user_language = $default_language; + } + + $_SESSION['vtiger_authenticated_user_theme'] = $authenticated_user_theme; + $_SESSION['authenticated_user_language'] = $authenticated_user_language; + + $log->debug("authenticated_user_theme is $authenticated_user_theme"); + $log->debug("authenticated_user_language is $authenticated_user_language"); + $log->debug("authenticated_user_id is ". $focus->id); + $log->debug("app_unique_key is $application_unique_key"); + + +// Clear all uploaded import files for this user if it exists + + global $import_dir; + + $tmp_file_name = $import_dir. "IMPORT_".$focus->id; + + if (file_exists($tmp_file_name)) + { + unlink($tmp_file_name); + } + $arr = $_SESSION['lastpage']; + if(isset($_SESSION['lastpage'])) + header("Location: index.php?".$arr[0]); + else + header("Location: index.php"); +} +else +{ + $sql = 'select user_name, id, crypt_type from vtiger_users where user_name=?'; + $result = $adb->pquery($sql, array($focus->column_fields["user_name"])); + $rowList = $result->GetRows(); + foreach ($rowList as $row) { + $cryptType = $row['crypt_type']; + if(strtolower($cryptType) == 'md5' && version_compare(PHP_VERSION, '5.3.0') >= 0) { + header("Location: modules/Migration/PHP5.3_PasswordHelp.php"); + die; + } + } + $_SESSION['login_user_name'] = $focus->column_fields["user_name"]; + $_SESSION['login_password'] = $user_password; + $_SESSION['login_error'] = $mod_strings['ERR_INVALID_PASSWORD']; + + // go back to the login screen. + // create an error message for the user. + header("Location: index.php"); +} + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Users/ChangePassword.php b/oss/vtiger/trunk/modules/Users/ChangePassword.php new file mode 100644 index 00000000..b7d81e15 --- /dev/null +++ b/oss/vtiger/trunk/modules/Users/ChangePassword.php @@ -0,0 +1,111 @@ + + + + +
+'; + print_r($account_share_read_per['GROUP']); + echo '';*/ + $newbuf .= "\$Accounts_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($account_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($account_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Accounts_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($account_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($account_share_write_per['GROUP']).");\n\n"; + + //Constructing Contact Sharing Rules + $newbuf .= "\$Contacts_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($account_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($account_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Contacts_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($account_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($account_share_write_per['GROUP']).");\n\n"; + + + + + + //Constructing the Account Potential Related Module Sharing Array + $acct_related_pot=getRelatedModuleSharingArray("Accounts","Potentials",$account_sharingrule_members,$account_share_read_per,$account_share_write_per,$def_org_share); + + $acc_pot_share_read_per=$acct_related_pot['read']; + $acc_pot_share_write_per=$acct_related_pot['write']; + + $newbuf .= "\$Accounts_Potentials_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_pot_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_pot_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Accounts_Potentials_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_pot_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_pot_share_write_per['GROUP']).");\n\n"; + + //Constructing the Account Ticket Related Module Sharing Array + $acct_related_tkt=getRelatedModuleSharingArray("Accounts","HelpDesk",$account_sharingrule_members,$account_share_read_per,$account_share_write_per,$def_org_share); + + $acc_tkt_share_read_per=$acct_related_tkt['read']; + $acc_tkt_share_write_per=$acct_related_tkt['write']; + + $newbuf .= "\$Accounts_HelpDesk_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_tkt_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_tkt_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Accounts_HelpDesk_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_tkt_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_tkt_share_write_per['GROUP']).");\n\n"; + + //Constructing the Account Email Related Module Sharing Array + $acct_related_email=getRelatedModuleSharingArray("Accounts","Emails",$account_sharingrule_members,$account_share_read_per,$account_share_write_per,$def_org_share); + + $acc_email_share_read_per=$acct_related_email['read']; + $acc_email_share_write_per=$acct_related_email['write']; + + $newbuf .= "\$Accounts_Emails_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_email_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_email_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Accounts_Emails_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_email_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_email_share_write_per['GROUP']).");\n\n"; + + //Constructing the Account Quote Related Module Sharing Array + $acct_related_qt=getRelatedModuleSharingArray("Accounts","Quotes",$account_sharingrule_members,$account_share_read_per,$account_share_write_per,$def_org_share); + + $acc_qt_share_read_per=$acct_related_qt['read']; + $acc_qt_share_write_per=$acct_related_qt['write']; + + $newbuf .= "\$Accounts_Quotes_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_qt_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_qt_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Accounts_Quotes_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_qt_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_qt_share_write_per['GROUP']).");\n\n"; + + //Constructing the Account SalesOrder Related Module Sharing Array + $acct_related_so=getRelatedModuleSharingArray("Accounts","SalesOrder",$account_sharingrule_members,$account_share_read_per,$account_share_write_per,$def_org_share); + + $acc_so_share_read_per=$acct_related_so['read']; + $acc_so_share_write_per=$acct_related_so['write']; + + $newbuf .= "\$Accounts_SalesOrder_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_so_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_so_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Accounts_SalesOrder_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_so_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_so_share_write_per['GROUP']).");\n\n"; + + + //Constructing the Account Invoice Related Module Sharing Array + $acct_related_inv=getRelatedModuleSharingArray("Accounts","Invoice",$account_sharingrule_members,$account_share_read_per,$account_share_write_per,$def_org_share); + + $acc_inv_share_read_per=$acct_related_inv['read']; + $acc_inv_share_write_per=$acct_related_inv['write']; + + $newbuf .= "\$Accounts_Invoice_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_inv_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_inv_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Accounts_Invoice_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($acc_inv_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($acc_inv_share_write_per['GROUP']).");\n\n"; + + + //Constructing Potential Sharing Rules + $pot_share_per_array=getUserModuleSharingObjects("Potentials",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + $pot_share_read_per=$pot_share_per_array['read']; + $pot_share_write_per=$pot_share_per_array['write']; + $pot_sharingrule_members=$pot_share_per_array['sharingrules']; + $newbuf .= "\$Potentials_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($pot_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalArray($pot_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Potentials_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($pot_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalArray($pot_share_write_per['GROUP']).");\n\n"; + + //Constructing the Potential Quotes Related Module Sharing Array + $pot_related_qt=getRelatedModuleSharingArray("Potentials","Quotes",$pot_sharingrule_members,$pot_share_read_per,$pot_share_write_per,$def_org_share); + + $pot_qt_share_read_per=$pot_related_qt['read']; + $pot_qt_share_write_per=$pot_related_qt['write']; + + $newbuf .= "\$Potentials_Quotes_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($pot_qt_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($pot_qt_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Potentials_Quotes_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($pot_qt_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($pot_qt_share_write_per['GROUP']).");\n\n"; + + //Constructing the Potential SalesOrder Related Module Sharing Array + $pot_related_inv=getRelatedModuleSharingArray("Potentials","SalesOrder",$pot_sharingrule_members,$pot_share_read_per,$pot_share_write_per,$def_org_share); + + + + $pot_inv_share_read_per=$pot_related_inv['read']; + $pot_inv_share_write_per=$pot_related_inv['write']; + + $newbuf .= "\$Potentials_SalesOrder_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($pot_inv_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($pot_inv_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Potentials_SalesOrder_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($pot_inv_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($pot_inv_share_write_per['GROUP']).");\n\n"; + + + + + //Constructing HelpDesk Sharing Rules + $hd_share_per_array=getUserModuleSharingObjects("HelpDesk",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + $hd_share_read_per=$hd_share_per_array['read']; + $hd_share_write_per=$hd_share_per_array['write']; + $newbuf .= "\$HelpDesk_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($hd_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalArray($hd_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$HelpDesk_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($hd_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalArray($hd_share_write_per['GROUP']).");\n\n"; + + //Constructing Emails Sharing Rules + $email_share_per_array=getUserModuleSharingObjects("Emails",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + $email_share_read_per=$email_share_per_array['read']; + $email_share_write_per=$email_share_per_array['write']; + $newbuf .= "\$Emails_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($email_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($email_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Emails_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($email_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($email_share_write_per['GROUP']).");\n\n"; + + //Constructing Campaigns Sharing Rules + $campaign_share_per_array=getUserModuleSharingObjects("Campaigns",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + $campaign_share_read_per=$campaign_share_per_array['read']; + $campaign_share_write_per=$campaign_share_per_array['write']; + $newbuf .= "\$Campaigns_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($campaign_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($campaign_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Campaigns_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($campaign_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($campaign_share_write_per['GROUP']).");\n\n"; + + + //Constructing Quotes Sharing Rules + $quotes_share_per_array=getUserModuleSharingObjects("Quotes",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + $quotes_share_read_per=$quotes_share_per_array['read']; + $quotes_share_write_per=$quotes_share_per_array['write']; + $quotes_sharingrule_members=$quotes_share_per_array['sharingrules']; + $newbuf .= "\$Quotes_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($quotes_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($quotes_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Quotes_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($quotes_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($quotes_share_write_per['GROUP']).");\n\n"; + + //Constructing the Quote SalesOrder Related Module Sharing Array + $qt_related_so=getRelatedModuleSharingArray("Quotes","SalesOrder",$quotes_sharingrule_members,$quotes_share_read_per,$quotes_share_write_per,$def_org_share); + + $qt_so_share_read_per=$qt_related_so['read']; + $qt_so_share_write_per=$qt_related_so['write']; + + $newbuf .= "\$Quotes_SalesOrder_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($qt_so_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($qt_so_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Quotes_SalesOrder_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($qt_so_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($qt_so_share_write_per['GROUP']).");\n\n"; + + + + + //Constructing Orders Sharing Rules + $po_share_per_array=getUserModuleSharingObjects("PurchaseOrder",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + $po_share_read_per=$po_share_per_array['read']; + $po_share_write_per=$po_share_per_array['write']; + $newbuf .= "\$PurchaseOrder_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($po_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalArray($po_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$PurchaseOrder_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($po_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalArray($po_share_write_per['GROUP']).");\n\n"; + + //Constructing Sales Order Sharing Rules + $so_share_per_array=getUserModuleSharingObjects("SalesOrder",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + $so_share_read_per=$so_share_per_array['read']; + $so_share_write_per=$so_share_per_array['write']; + $so_sharingrule_members=$so_share_per_array['sharingrules']; + $newbuf .= "\$SalesOrder_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($so_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($so_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$SalesOrder_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($so_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($so_share_write_per['GROUP']).");\n\n"; + + //Constructing the SalesOrder Invoice Related Module Sharing Array + $so_related_inv=getRelatedModuleSharingArray("SalesOrder","Invoice",$so_sharingrule_members,$so_share_read_per,$so_share_write_per,$def_org_share); + + $so_inv_share_read_per=$so_related_inv['read']; + $so_inv_share_write_per=$so_related_inv['write']; + + $newbuf .= "\$SalesOrder_Invoice_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($so_inv_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($so_inv_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$SalesOrder_Invoice_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($so_inv_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($so_inv_share_write_per['GROUP']).");\n\n"; + + + + //Constructing Invoice Sharing Rules + $inv_share_per_array=getUserModuleSharingObjects("Invoice",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + $inv_share_read_per=$inv_share_per_array['read']; + $inv_share_write_per=$inv_share_per_array['write']; + $newbuf .= "\$Invoice_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($inv_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalArray($inv_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Invoice_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($inv_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalArray($inv_share_write_per['GROUP']).");\n\n"; + + // Writing Sharing Rules For Custom Modules. + // TODO: We are ignoring rules that has already been calculated above, it is good to add GENERIC logic here. + $custom_modules = getSharingModuleList( + Array('Leads', 'Accounts', 'Contacts', 'Potentials', 'HelpDesk', + 'Emails', 'Campaigns','Quotes', 'PurchaseOrder', 'SalesOrder', 'Invoice')); + + for($idx = 0; $idx < count($custom_modules); ++$idx) { + $module_name = $custom_modules[$idx]; + $mod_share_perm_array = getUserModuleSharingObjects($module_name,$userid, + $def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + + $mod_share_read_perm = $mod_share_perm_array['read']; + $mod_share_write_perm= $mod_share_perm_array['write']; + $newbuf .= '$'.$module_name."_share_read_permission=array('ROLE'=>". + constructTwoDimensionalCharIntSingleValueArray($mod_share_read_perm['ROLE']).",'GROUP'=>". + constructTwoDimensionalArray($mod_share_read_perm['GROUP']).");\n\n"; + $newbuf .= '$'.$module_name."_share_write_permission=array('ROLE'=>". + constructTwoDimensionalCharIntSingleValueArray($mod_share_write_perm['ROLE']).",'GROUP'=>". + constructTwoDimensionalArray($mod_share_write_perm['GROUP']).");\n\n"; + } + // END + + $newbuf .= "?>"; + fputs($handle, $newbuf); + fclose($handle); + + //Populating Temp Tables + populateSharingtmptables($userid); + } + } +} + +/** Gives an array which contains the information for what all roles, groups and user data is to be shared with the spcified user for the specified module + + * @param $module -- module name:: Type varchar + * @param $userid -- user id:: Type integer + * @param $def_org_share -- default organization sharing permission array:: Type array + * @param $current_user_roles -- roleid:: Type varchar + * @param $parent_roles -- parent roles:: Type varchar + * @param $current_user_groups -- user id:: Type integer + * @returns $mod_share_permission -- array which contains the id of roles,group and users data shared with specifed user for the specified module + */ +function getUserModuleSharingObjects($module,$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups) +{ + global $adb; + + $mod_tabid=getTabid($module); + + $mod_share_permission; + $mod_share_read_permission=Array(); + $mod_share_write_permission=Array(); + $mod_share_read_permission['ROLE']=Array(); + $mod_share_write_permission['ROLE']=Array(); + $mod_share_read_permission['GROUP']=Array(); + $mod_share_write_permission['GROUP']=Array(); + + $share_id_members=Array(); + $share_id_groupmembers=Array(); + //If Sharing of leads is Private + if($def_org_share[$mod_tabid] == 3 || $def_org_share[$mod_tabid] == 0) + { + $role_read_per=Array(); + $role_write_per=Array(); + $rs_read_per=Array(); + $rs_write_per=Array(); + $grp_read_per=Array(); + $grp_write_per=Array(); + //Retreiving from vtiger_role to vtiger_role + $query="select vtiger_datashare_role2role.* from vtiger_datashare_role2role inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_role2role.shareid where vtiger_datashare_module_rel.tabid=? and vtiger_datashare_role2role.to_roleid=?"; + $result=$adb->pquery($query, array($mod_tabid, $current_user_roles)); + $num_rows=$adb->num_rows($result); + for($i=0;$i<$num_rows;$i++) + { + $share_roleid=$adb->query_result($result,$i,'share_roleid'); + + $shareid=$adb->query_result($result,$i,'shareid'); + $share_id_role_members=Array(); + $share_id_roles=Array(); + $share_id_roles[]=$share_roleid; + $share_id_role_members['ROLE']=$share_id_roles; + $share_id_members[$shareid]=$share_id_role_members; + + $share_permission=$adb->query_result($result,$i,'permission'); + if($share_permission == 1) + { + if($def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + } + if(! array_key_exists($share_roleid,$role_write_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_write_per[$share_roleid]=$share_role_users; + } + } + elseif($share_permission == 0 && $def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + + } + + } + + + + //Retreiving from role to rs + $parRoleList = array(); + foreach($parent_roles as $par_role_id) + { + array_push($parRoleList, $par_role_id); + } + array_push($parRoleList, $current_user_roles); + $query="select vtiger_datashare_role2rs.* from vtiger_datashare_role2rs inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_role2rs.shareid where vtiger_datashare_module_rel.tabid=? and vtiger_datashare_role2rs.to_roleandsubid in (". generateQuestionMarks($parRoleList) .")"; + $result=$adb->pquery($query, array($mod_tabid, $parRoleList)); + $num_rows=$adb->num_rows($result); + for($i=0;$i<$num_rows;$i++) + { + $share_roleid=$adb->query_result($result,$i,'share_roleid'); + + $shareid=$adb->query_result($result,$i,'shareid'); + $share_id_role_members=Array(); + $share_id_roles=Array(); + $share_id_roles[]=$share_roleid; + $share_id_role_members['ROLE']=$share_id_roles; + $share_id_members[$shareid]=$share_id_role_members; + + $share_permission=$adb->query_result($result,$i,'permission'); + if($share_permission == 1) + { + if($def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + } + if(! array_key_exists($share_roleid,$role_write_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_write_per[$share_roleid]=$share_role_users; + } + } + elseif($share_permission == 0 && $def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + + } + + } + + //Get roles from Role2Grp + $grpIterator=false; + $groupList = $current_user_groups; + if (!empty($groupList)) { + $query="select vtiger_datashare_role2group.* from vtiger_datashare_role2group inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_role2group.shareid where vtiger_datashare_module_rel.tabid=?"; + $qparams = array($mod_tabid); + if (count($groupList) > 0) { + $query .= " and vtiger_datashare_role2group.to_groupid in (". generateQuestionMarks($groupList) .")"; + array_push($qparams, $groupList); + } + $result=$adb->pquery($query, $qparams); + $num_rows=$adb->num_rows($result); + for($i=0;$i<$num_rows;$i++) + { + $share_roleid=$adb->query_result($result,$i,'share_roleid'); + $shareid=$adb->query_result($result,$i,'shareid'); + $share_id_role_members=Array(); + $share_id_roles=Array(); + $share_id_roles[]=$share_roleid; + $share_id_role_members['ROLE']=$share_id_roles; + $share_id_members[$shareid]=$share_id_role_members; + + $share_permission=$adb->query_result($result,$i,'permission'); + if($share_permission == 1) + { + if($def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + } + if(! array_key_exists($share_roleid,$role_write_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_write_per[$share_roleid]=$share_role_users; + } + } + elseif($share_permission == 0 && $def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + + } + + } + } + + + //Retreiving from rs to vtiger_role + $query="select vtiger_datashare_rs2role.* from vtiger_datashare_rs2role inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_rs2role.shareid where vtiger_datashare_module_rel.tabid=? and vtiger_datashare_rs2role.to_roleid=?"; + $result=$adb->pquery($query, array($mod_tabid, $current_user_roles)); + $num_rows=$adb->num_rows($result); + for($i=0;$i<$num_rows;$i++) + { + $share_rsid=$adb->query_result($result,$i,'share_roleandsubid'); + $share_roleids=getRoleAndSubordinatesRoleIds($share_rsid); + $share_permission=$adb->query_result($result,$i,'permission'); + + $shareid=$adb->query_result($result,$i,'shareid'); + $share_id_role_members=Array(); + $share_id_roles=Array(); + foreach($share_roleids as $share_roleid) + { + $share_id_roles[]=$share_roleid; + + + if($share_permission == 1) + { + if($def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + } + if(! array_key_exists($share_roleid,$role_write_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_write_per[$share_roleid]=$share_role_users; + } + } + elseif($share_permission == 0 && $def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + + } + } + $share_id_role_members['ROLE']=$share_id_roles; + $share_id_members[$shareid]=$share_id_role_members; + + } + + + //Retreiving from rs to rs + $parRoleList = array(); + foreach($parent_roles as $par_role_id) + { + array_push($parRoleList, $par_role_id); + } + array_push($parRoleList, $current_user_roles); + $query="select vtiger_datashare_rs2rs.* from vtiger_datashare_rs2rs inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_rs2rs.shareid where vtiger_datashare_module_rel.tabid=? and vtiger_datashare_rs2rs.to_roleandsubid in (". generateQuestionMarks($parRoleList) .")"; + $result=$adb->pquery($query, array($mod_tabid, $parRoleList)); + $num_rows=$adb->num_rows($result); + for($i=0;$i<$num_rows;$i++) + { + $share_rsid=$adb->query_result($result,$i,'share_roleandsubid'); + $share_roleids=getRoleAndSubordinatesRoleIds($share_rsid); + $share_permission=$adb->query_result($result,$i,'permission'); + + $shareid=$adb->query_result($result,$i,'shareid'); + $share_id_role_members=Array(); + $share_id_roles=Array(); + foreach($share_roleids as $share_roleid) + { + + $share_id_roles[]=$share_roleid; + + if($share_permission == 1) + { + if($def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + } + if(! array_key_exists($share_roleid,$role_write_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_write_per[$share_roleid]=$share_role_users; + } + } + elseif($share_permission == 0 && $def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + + } + } + $share_id_role_members['ROLE']=$share_id_roles; + $share_id_members[$shareid]=$share_id_role_members; + + } + + //Get roles from Rs2Grp + + $query="select vtiger_datashare_rs2grp.* from vtiger_datashare_rs2grp inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_rs2grp.shareid where vtiger_datashare_module_rel.tabid=?"; + $qparams = array($mod_tabid); + if (count($groupList) > 0) { + $query .= " and vtiger_datashare_rs2grp.to_groupid in (". generateQuestionMarks($groupList) .")"; + array_push($qparams, $groupList); + } + $result=$adb->pquery($query, $qparams); + $num_rows=$adb->num_rows($result); + for($i=0;$i<$num_rows;$i++) + { + $share_rsid=$adb->query_result($result,$i,'share_roleandsubid'); + $share_roleids=getRoleAndSubordinatesRoleIds($share_rsid); + $share_permission=$adb->query_result($result,$i,'permission'); + + $shareid=$adb->query_result($result,$i,'shareid'); + $share_id_role_members=Array(); + $share_id_roles=Array(); + + foreach($share_roleids as $share_roleid) + { + + $share_id_roles[]=$share_roleid; + + if($share_permission == 1) + { + if($def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + } + if(! array_key_exists($share_roleid,$role_write_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_write_per[$share_roleid]=$share_role_users; + } + } + elseif($share_permission == 0 && $def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_roleid,$role_read_per)) + { + + $share_role_users=getRoleUserIds($share_roleid); + $role_read_per[$share_roleid]=$share_role_users; + } + + } + } + $share_id_role_members['ROLE']=$share_id_roles; + $share_id_members[$shareid]=$share_id_role_members; + + + + } + $mod_share_read_permission['ROLE']=$role_read_per; + $mod_share_write_permission['ROLE']=$role_write_per; + + //Retreiving from the grp2role sharing + $query="select vtiger_datashare_grp2role.* from vtiger_datashare_grp2role inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_grp2role.shareid where vtiger_datashare_module_rel.tabid=? and vtiger_datashare_grp2role.to_roleid=?"; + $result=$adb->pquery($query, array($mod_tabid, $current_user_roles)); + $num_rows=$adb->num_rows($result); + for($i=0;$i<$num_rows;$i++) + { + $share_grpid=$adb->query_result($result,$i,'share_groupid'); + $share_permission=$adb->query_result($result,$i,'permission'); + + $shareid=$adb->query_result($result,$i,'shareid'); + $share_id_grp_members=Array(); + $share_id_grps=Array(); + $share_id_grps[]=$share_grpid; + + + if($share_permission == 1) + { + if($def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_grpid,$grp_read_per)) + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($share_grpid); + $share_grp_users=$focusGrpUsers->group_users; + $share_grp_subgroups=$focusGrpUsers->group_subgroups; + $grp_read_per[$share_grpid]=$share_grp_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_read_per)) + { + $grp_read_per[$subgrpid]=$subgrpusers; + } + if(! in_array($subgrpid,$share_id_grps)) + { + $share_id_grps[]=$subgrpid; + } + + } + } + } + if(! array_key_exists($share_grpid,$grp_write_per)) + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($share_grpid); + $share_grp_users=$focusGrpUsers->group_users; + $grp_write_per[$share_grpid]=$share_grp_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_write_per)) + { + $grp_write_per[$subgrpid]=$subgrpusers; + } + if(! in_array($subgrpid,$share_id_grps)) + { + $share_id_grps[]=$subgrpid; + } + + } + + } + } + elseif($share_permission == 0 && $def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_grpid,$grp_read_per)) + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($share_grpid); + $share_grp_users=$focusGrpUsers->group_users; + $grp_read_per[$share_grpid]=$share_grp_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_read_per)) + { + $grp_read_per[$subgrpid]=$subgrpusers; + } + if(! in_array($subgrpid,$share_id_grps)) + { + $share_id_grps[]=$subgrpid; + } + + } + } + + } + $share_id_grp_members['GROUP']=$share_id_grps; + $share_id_members[$shareid]=$share_id_grp_members; + + } + + //Retreiving from the grp2rs sharing + + $query="select vtiger_datashare_grp2rs.* from vtiger_datashare_grp2rs inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_grp2rs.shareid where vtiger_datashare_module_rel.tabid=? and vtiger_datashare_grp2rs.to_roleandsubid in (". generateQuestionMarks($parRoleList) .")"; + $result=$adb->pquery($query, array($mod_tabid, $parRoleList)); + $num_rows=$adb->num_rows($result); + for($i=0;$i<$num_rows;$i++) + { + $share_grpid=$adb->query_result($result,$i,'share_groupid'); + $share_permission=$adb->query_result($result,$i,'permission'); + + $shareid=$adb->query_result($result,$i,'shareid'); + $share_id_grp_members=Array(); + $share_id_grps=Array(); + $share_id_grps[]=$share_grpid; + + + if($share_permission == 1) + { + if($def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_grpid,$grp_read_per)) + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($share_grpid); + $share_grp_users=$focusGrpUsers->group_users; + $grp_read_per[$share_grpid]=$share_grp_users; + + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_read_per)) + { + $grp_read_per[$subgrpid]=$subgrpusers; + } + if(! in_array($subgrpid,$share_id_grps)) + { + $share_id_grps[]=$subgrpid; + } + + } + } + } + if(! array_key_exists($share_grpid,$grp_write_per)) + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($share_grpid); + $share_grp_users=$focusGrpUsers->group_users; + $grp_write_per[$share_grpid]=$share_grp_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_write_per)) + { + $grp_write_per[$subgrpid]=$subgrpusers; + } + if(! in_array($subgrpid,$share_id_grps)) + { + $share_id_grps[]=$subgrpid; + } + + } + + } + } + elseif($share_permission == 0 && $def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_grpid,$grp_read_per)) + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($share_grpid); + $share_grp_users=$focusGrpUsers->group_users; + $grp_read_per[$share_grpid]=$share_grp_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_read_per)) + { + $grp_read_per[$subgrpid]=$subgrpusers; + } + if(! in_array($subgrpid,$share_id_grps)) + { + $share_id_grps[]=$subgrpid; + } + + } + } + + } + $share_id_grp_members['GROUP']=$share_id_grps; + $share_id_members[$shareid]=$share_id_grp_members; + + } + + //Retreiving from the grp2grp sharing + + $query="select vtiger_datashare_grp2grp.* from vtiger_datashare_grp2grp inner join vtiger_datashare_module_rel on vtiger_datashare_module_rel.shareid=vtiger_datashare_grp2grp.shareid where vtiger_datashare_module_rel.tabid=?"; + $qparams = array($mod_tabid); + if (count($groupList) > 0) { + $query .= " and vtiger_datashare_grp2grp.to_groupid in (". generateQuestionMarks($groupList) .")"; + array_push($qparams, $groupList); + } + $result=$adb->pquery($query, $qparams); + $num_rows=$adb->num_rows($result); + for($i=0;$i<$num_rows;$i++) + { + $share_grpid=$adb->query_result($result,$i,'share_groupid'); + $share_permission=$adb->query_result($result,$i,'permission'); + + $shareid=$adb->query_result($result,$i,'shareid'); + $share_id_grp_members=Array(); + $share_id_grps=Array(); + $share_id_grps[]=$share_grpid; + + if($share_permission == 1) + { + if($def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_grpid,$grp_read_per)) + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($share_grpid); + $share_grp_users=$focusGrpUsers->group_users; + $grp_read_per[$share_grpid]=$share_grp_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_read_per)) + { + $grp_read_per[$subgrpid]=$subgrpusers; + } + if(! in_array($subgrpid,$share_id_grps)) + { + $share_id_grps[]=$subgrpid; + } + + + } + } + } + if(! array_key_exists($share_grpid,$grp_write_per)) + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($share_grpid); + $share_grp_users=$focusGrpUsers->group_users; + $grp_write_per[$share_grpid]=$share_grp_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_write_per)) + { + $grp_write_per[$subgrpid]=$subgrpusers; + } + if(! in_array($subgrpid,$share_id_grps)) + { + $share_id_grps[]=$subgrpid; + } + + } + + } + } + elseif($share_permission == 0 && $def_org_share[$mod_tabid] == 3) + { + if(! array_key_exists($share_grpid,$grp_read_per)) + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($share_grpid); + $share_grp_users=$focusGrpUsers->group_users; + $grp_read_per[$share_grpid]=$share_grp_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_read_per)) + { + $grp_read_per[$subgrpid]=$subgrpusers; + } + if(! in_array($subgrpid,$share_id_grps)) + { + $share_id_grps[]=$subgrpid; + } + + } + } + + } + $share_id_grp_members['GROUP']=$share_id_grps; + $share_id_members[$shareid]=$share_id_grp_members; + + } + $mod_share_read_permission['GROUP']=$grp_read_per; + $mod_share_write_permission['GROUP']=$grp_write_per; + } + $mod_share_permission['read']=$mod_share_read_permission; + $mod_share_permission['write']=$mod_share_write_permission; + $mod_share_permission['sharingrules']=$share_id_members; + return $mod_share_permission; +} + +/** Gives an array which contains the information for what all roles, groups and user's related module data that is to be shared for the specified parent module and shared module + + * @param $par_mod -- parent module name:: Type varchar + * @param $share_mod -- shared module name:: Type varchar + * @param $userid -- user id:: Type integer + * @param $def_org_share -- default organization sharing permission array:: Type array + * @param $mod_sharingrule_members -- Sharing Rule Members array:: Type array + * @param $$mod_share_read_per -- Sharing Module Read Permission array:: Type array + * @param $$mod_share_write_per -- Sharing Module Write Permission array:: Type array + * @returns $related_mod_sharing_permission; -- array which contains the id of roles,group and users related module data to be shared + */ +function getRelatedModuleSharingArray($par_mod,$share_mod,$mod_sharingrule_members,$mod_share_read_per,$mod_share_write_per,$def_org_share) +{ + + global $adb; + $related_mod_sharing_permission=Array(); + $mod_share_read_permission=Array(); + $mod_share_write_permission=Array(); + + $mod_share_read_permission['ROLE']=Array(); + $mod_share_write_permission['ROLE']=Array(); + $mod_share_read_permission['GROUP']=Array(); + $mod_share_write_permission['GROUP']=Array(); + + $par_mod_id=getTabid($par_mod); + $share_mod_id=getTabid($share_mod); + + if($def_org_share[$share_mod_id] == 3 || $def_org_share[$share_mod_id] == 0) + { + + $role_read_per=Array(); + $role_write_per=Array(); + $grp_read_per=Array(); + $grp_write_per=Array(); + + + + foreach($mod_sharingrule_members as $sharingid => $sharingInfoArr) + { + $query = "select vtiger_datashare_relatedmodule_permission.* from vtiger_datashare_relatedmodule_permission inner join vtiger_datashare_relatedmodules on vtiger_datashare_relatedmodules.datashare_relatedmodule_id=vtiger_datashare_relatedmodule_permission.datashare_relatedmodule_id where vtiger_datashare_relatedmodule_permission.shareid=? and vtiger_datashare_relatedmodules.tabid=? and vtiger_datashare_relatedmodules.relatedto_tabid=?"; + $result=$adb->pquery($query, array($sharingid, $par_mod_id, $share_mod_id)); + $share_permission=$adb->query_result($result,0,'permission'); + + foreach($sharingInfoArr as $shareType => $shareEntArr) + { + foreach($shareEntArr as $key=>$shareEntId) + { + if($shareType == 'ROLE') + { + if($share_permission == 1) + { + if($def_org_share[$share_mod_id] == 3) + { + if(! array_key_exists($shareEntId,$role_read_per)) + { + if(array_key_exists($shareEntId,$mod_share_read_per['ROLE'])) + { + $share_role_users=$mod_share_read_per['ROLE'][$shareEntId]; + } + elseif(array_key_exists($shareEntId,$mod_share_write_per['ROLE'])) + { + $share_role_users=$mod_share_write_per['ROLE'][$shareEntId]; + } + else + { + + $share_role_users=getRoleUserIds($shareEntId); + } + + $role_read_per[$shareEntId]=$share_role_users; + + } + } + if(! array_key_exists($shareEntId,$role_write_per)) + { + if(array_key_exists($shareEntId,$mod_share_read_per['ROLE'])) + { + $share_role_users=$mod_share_read_per['ROLE'][$shareEntId]; + } + elseif(array_key_exists($shareEntId,$mod_share_write_per['ROLE'])) + { + $share_role_users=$mod_share_write_per['ROLE'][$shareEntId]; + } + else + { + + $share_role_users=getRoleUserIds($shareEntId); + + } + + $role_write_per[$shareEntId]=$share_role_users; + } + } + elseif($share_permission == 0 && $def_org_share[$share_mod_id] == 3) + { + if(! array_key_exists($shareEntId,$role_read_per)) + { + if(array_key_exists($shareEntId,$mod_share_read_per['ROLE'])) + { + $share_role_users=$mod_share_read_per['ROLE'][$shareEntId]; + } + elseif(array_key_exists($shareEntId,$mod_share_write_per['ROLE'])) + { + $share_role_users=$mod_share_write_per['ROLE'][$shareEntId]; + } + else + { + + $share_role_users=getRoleUserIds($shareEntId); + } + + $role_read_per[$shareEntId]=$share_role_users; + + } + + + } + + } + elseif($shareType == 'GROUP') + { + if($share_permission == 1) + { + if($def_org_share[$share_mod_id] == 3) + { + + if(! array_key_exists($shareEntId,$grp_read_per)) + { + if(array_key_exists($shareEntId,$mod_share_read_per['GROUP'])) + { + $share_grp_users=$mod_share_read_per['GROUP'][$shareEntId]; + } + elseif(array_key_exists($shareEntId,$mod_share_write_per['GROUP'])) + { + $share_grp_users=$mod_share_write_per['GROUP'][$shareEntId]; + } + else + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($shareEntId); + $share_grp_users=$focusGrpUsers->group_users; + + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_read_per)) + { + $grp_read_per[$subgrpid]=$subgrpusers; + } + + } + + } + + $grp_read_per[$shareEntId]=$share_grp_users; + + } + } + if(! array_key_exists($shareEntId,$grp_write_per)) + { + if(! array_key_exists($shareEntId,$grp_write_per)) + { + if(array_key_exists($shareEntId,$mod_share_read_per['GROUP'])) + { + $share_grp_users=$mod_share_read_per['GROUP'][$shareEntId]; + } + elseif(array_key_exists($shareEntId,$mod_share_write_per['GROUP'])) + { + $share_grp_users=$mod_share_write_per['GROUP'][$shareEntId]; + } + else + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($shareEntId); + $share_grp_users=$focusGrpUsers->group_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_write_per)) + { + $grp_write_per[$subgrpid]=$subgrpusers; + } + + } + + } + + $grp_write_per[$shareEntId]=$share_grp_users; + + } + } + } + elseif($share_permission == 0 && $def_org_share[$share_mod_id] == 3) + { + if(! array_key_exists($shareEntId,$grp_read_per)) + { + if(array_key_exists($shareEntId,$mod_share_read_per['GROUP'])) + { + $share_grp_users=$mod_share_read_per['GROUP'][$shareEntId]; + } + elseif(array_key_exists($shareEntId,$mod_share_write_per['GROUP'])) + { + $share_grp_users=$mod_share_write_per['GROUP'][$shareEntId]; + } + else + { + $focusGrpUsers = new GetGroupUsers(); + $focusGrpUsers->getAllUsersInGroup($shareEntId); + $share_grp_users=$focusGrpUsers->group_users; + foreach($focusGrpUsers->group_subgroups as $subgrpid=>$subgrpusers) + { + if(! array_key_exists($subgrpid,$grp_read_per)) + { + $grp_read_per[$subgrpid]=$subgrpusers; + } + + } + + } + + $grp_read_per[$shareEntId]=$share_grp_users; + + } + + + } + } + } + } + } + $mod_share_read_permission['ROLE']=$role_read_per; + $mod_share_write_permission['ROLE']=$role_write_per; + $mod_share_read_permission['GROUP']=$grp_read_per; + $mod_share_write_permission['GROUP']=$grp_write_per; + } + + $related_mod_sharing_permission['read']=$mod_share_read_permission; + $related_mod_sharing_permission['write']=$mod_share_write_permission; + return $related_mod_sharing_permission; + + +} + + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructArray($var) +{ + if (is_array($var)) + { + $code = 'array('; + foreach ($var as $key => $value) + { + $code .= "'".$key."'=>".$value.','; + } + $code .= ')'; + return $code; + } +} + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructSingleStringValueArray($var) +{ + + $size = sizeof($var); + $i=1; + if (is_array($var)) + { + $code = 'array('; + foreach ($var as $key => $value) + { + if($i<$size) + { + $code .= $key."=>'".$value."',"; + } + else + { + $code .= $key."=>'".$value."'"; + } + $i++; + } + $code .= ')'; + return $code; + } +} + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructSingleStringKeyAndValueArray($var) +{ + + $size = sizeof($var); + $i=1; + if (is_array($var)) + { + $code = 'array('; + foreach ($var as $key => $value) + { + if($i<$size) + { + $code .= "'".$key."'=>".$value.","; + } + else + { + $code .= "'".$key."'=>".$value; + } + $i++; + } + $code .= ')'; + return $code; + } +} + + + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructSingleStringKeyValueArray($var) { + global $adb; + $size = sizeof($var); + $i=1; + if (is_array($var)) { + $code = 'array('; + foreach ($var as $key => $value) { + //fix for signatue quote(') issue + $value=$adb->sql_escape_string($value); + if($i<$size) { + $code .= "'".$key."'=>'".$value."',"; + } else { + $code .= "'".$key."'=>'".$value."'"; + } + $i++; + } + $code .= ')'; + return $code; + } +} + + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructSingleArray($var) +{ + if (is_array($var)) + { + $code = 'array('; + foreach ($var as $value) + { + $code .= $value.','; + } + $code .= ')'; + return $code; + } +} + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructSingleCharArray($var) +{ + if (is_array($var)) + { + $code = "array("; + foreach ($var as $value) + { + $code .="'".$value."',"; + } + $code .= ")"; + return $code; + } +} + + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructTwoDimensionalArray($var) +{ + if (is_array($var)) + { + $code = 'array('; + foreach ($var as $key => $secarr) + { + $code .= $key.'=>array('; + foreach($secarr as $seckey => $secvalue) + { + $code .= $seckey.'=>'.$secvalue.','; + } + $code .= '),'; + } + $code .= ')'; + return $code; + } +} + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructTwoDimensionalValueArray($var) +{ + if (is_array($var)) + { + $code = 'array('; + foreach ($var as $key => $secarr) + { + $code .= $key.'=>array('; + foreach($secarr as $seckey => $secvalue) + { + $code .= $secvalue.','; + } + $code .= '),'; + } + $code .= ')'; + return $code; + } +} + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructTwoDimensionalCharIntSingleArray($var) +{ + if (is_array($var)) + { + $code = "array("; + foreach ($var as $key => $secarr) + { + $code .= "'".$key."'=>array("; + foreach($secarr as $seckey => $secvalue) + { + $code .= $seckey.","; + } + $code .= "),"; + } + $code .= ")"; + return $code; + } +} + +/** Converts the input array to a single string to facilitate the writing of the input array in a flat file + + * @param $var -- input array:: Type array + * @returns $code -- contains the whole array in a single string:: Type array + */ +function constructTwoDimensionalCharIntSingleValueArray($var) +{ + if (is_array($var)) + { + $code = "array("; + foreach ($var as $key => $secarr) + { + $code .= "'".$key."'=>array("; + foreach($secarr as $seckey => $secvalue) + { + $code .= $secvalue.","; + } + $code .= "),"; + } + $code .= ")"; + return $code; + } +} + + +/** Function to populate the read/wirte Sharing permissions data of user/groups for the specified user into the database + * @param $userid -- user id:: Type integer + */ + +function populateSharingtmptables($userid) +{ + global $adb; + require('user_privileges/sharing_privileges_'.$userid.'.php'); + //Deleting from the existing vtiger_tables + $table_arr=Array('vtiger_tmp_read_user_sharing_per', 'vtiger_tmp_write_user_sharing_per','vtiger_tmp_read_group_sharing_per','vtiger_tmp_write_group_sharing_per','vtiger_tmp_read_user_rel_sharing_per','vtiger_tmp_write_user_rel_sharing_per','vtiger_tmp_read_group_rel_sharing_per','vtiger_tmp_write_group_rel_sharing_per'); + foreach($table_arr as $tabname) + { + $query = "delete from ".$tabname." where userid=?"; + $adb->pquery($query, array($userid)); + } + + // Look up for modules for which sharing access is enabled. + $sharingArray = Array('Emails'); + $otherModules = getSharingModuleList(); + $sharingArray = array_merge($sharingArray, $otherModules); + + foreach($sharingArray as $module) + { + $module_sharing_read_permvar = $module.'_share_read_permission'; + $module_sharing_write_permvar = $module.'_share_write_permission'; + + populateSharingPrivileges('USER',$userid,$module,'read', $$module_sharing_read_permvar ); + populateSharingPrivileges('USER',$userid,$module,'write', $$module_sharing_write_permvar ); + populateSharingPrivileges('GROUP',$userid,$module,'read', $$module_sharing_read_permvar ); + populateSharingPrivileges('GROUP',$userid,$module,'write', $$module_sharing_write_permvar ); + } + //Populating Values into the temp related sharing tables + foreach($related_module_share as $rel_tab_id => $tabid_arr) + { + $rel_tab_name=getTabname($rel_tab_id); + foreach($tabid_arr as $taid) + { + $tab_name=getTabname($taid); + + $relmodule_sharing_read_permvar = $tab_name.'_'.$rel_tab_name.'_share_read_permission'; + $relmodule_sharing_write_permvar = $tab_name.'_'.$rel_tab_name.'_share_write_permission'; + + populateRelatedSharingPrivileges('USER',$userid,$tab_name,$rel_tab_name,'read', $$relmodule_sharing_read_permvar); + populateRelatedSharingPrivileges('USER',$userid,$tab_name,$rel_tab_name,'write', $$relmodule_sharing_write_permvar); + populateRelatedSharingPrivileges('GROUP',$userid,$tab_name,$rel_tab_name,'read', $$relmodule_sharing_read_permvar); + populateRelatedSharingPrivileges('GROUP',$userid,$tab_name,$rel_tab_name,'write', $$relmodule_sharing_write_permvar); + } + } +} + +/** Function to populate the read/wirte Sharing permissions data for the specified user into the database + * @param $userid -- user id:: Type integer + * @param $enttype -- can have the value of User or Group:: Type varchar + * @param $module -- module name:: Type varchar + * @param $pertype -- can have the value of read or write:: Type varchar + * @param $var_name_arr - Variable to use instead of including the sharing access again + */ +function populateSharingPrivileges($enttype,$userid,$module,$pertype, $var_name_arr=false) +{ + global $adb; + $tabid=getTabid($module); + + if(!$var_name_arr) { + require('user_privileges/sharing_privileges_'.$userid.'.php'); + } + + if($enttype=='USER') + { + if($pertype =='read') + { + $table_name='vtiger_tmp_read_user_sharing_per'; + $var_name=$module.'_share_read_permission'; + } + elseif($pertype == 'write') + { + $table_name='vtiger_tmp_write_user_sharing_per'; + $var_name=$module.'_share_write_permission'; + } + // Lookup for the variable if not set through function argument + if(!$var_name_arr) $var_name_arr=$$var_name; + $user_arr=Array(); + if(sizeof($var_name_arr['ROLE']) > 0) + { + foreach($var_name_arr['ROLE'] as $roleid=>$roleusers) + { + + foreach($roleusers as $user_id) + { + if(! in_array($user_id,$user_arr)) + { + $query="insert into ".$table_name." values(?,?,?)"; + $adb->pquery($query, array($userid, $tabid, $user_id)); + $user_arr[]=$user_id; + } + } + } + } + if(sizeof($var_name_arr['GROUP']) > 0) + { + foreach($var_name_arr['GROUP'] as $grpid=>$grpusers) + { + foreach($grpusers as $user_id) + { + if(! in_array($user_id,$user_arr)) + { + $query="insert into ".$table_name." values(?,?,?)"; + $adb->pquery($query, array($userid, $tabid, $user_id)); + $user_arr[]=$user_id; + } + } + } + } + + + } + elseif($enttype=='GROUP') + { + if($pertype =='read') + { + $table_name='vtiger_tmp_read_group_sharing_per'; + $var_name=$module.'_share_read_permission'; + } + elseif($pertype == 'write') + { + $table_name='vtiger_tmp_write_group_sharing_per'; + $var_name=$module.'_share_write_permission'; + } + // Lookup for the variable if not set through function argument + if(!$var_name_arr) $var_name_arr=$$var_name; + $grp_arr=Array(); + if(sizeof($var_name_arr['GROUP']) > 0) + { + + foreach($var_name_arr['GROUP'] as $grpid=>$grpusers) + { + if(! in_array($grpid,$grp_arr)) + { + $query="insert into ".$table_name." values(?,?,?)"; + $adb->pquery($query, array($userid, $tabid, $grpid)); + $grp_arr[]=$grpid; + } + } + } + + } + +} + + +/** Function to populate the read/wirte Sharing permissions related module data for the specified user into the database + * @param $userid -- user id:: Type integer + * @param $enttype -- can have the value of User or Group:: Type varchar + * @param $module -- module name:: Type varchar + * @param $relmodule -- related module name:: Type varchar + * @param $pertype -- can have the value of read or write:: Type varchar + * @param $var_name_arr - Variable to use instead of including the sharing access again + */ + +function populateRelatedSharingPrivileges($enttype,$userid,$module,$relmodule,$pertype, $var_name_arr=false) +{ + global $adb; + $tabid=getTabid($module); + $reltabid=getTabid($relmodule); + + if(!$var_name_arr) { + require('user_privileges/sharing_privileges_'.$userid.'.php'); + } + + if($enttype=='USER') + { + if($pertype =='read') + { + $table_name='vtiger_tmp_read_user_rel_sharing_per'; + $var_name=$module.'_'.$relmodule.'_share_read_permission'; + } + elseif($pertype == 'write') + { + $table_name='vtiger_tmp_write_user_rel_sharing_per'; + $var_name=$module.'_'.$relmodule.'_share_write_permission'; + } + // Lookup for the variable if not set through function argument + if(!$var_name_arr) $var_name_arr=$$var_name; + $user_arr=Array(); + if(sizeof($var_name_arr['ROLE']) > 0) + { + foreach($var_name_arr['ROLE'] as $roleid=>$roleusers) + { + + foreach($roleusers as $user_id) + { + if(! in_array($user_id,$user_arr)) + { + $query="insert into ".$table_name." values(?,?,?,?)"; + $adb->pquery($query, array($userid, $tabid, $reltabid, $user_id)); + $user_arr[]=$user_id; + } + } + } + } + if(sizeof($var_name_arr['GROUP']) > 0) + { + foreach($var_name_arr['GROUP'] as $grpid=>$grpusers) + { + foreach($grpusers as $user_id) + { + if(! in_array($user_id,$user_arr)) + { + $query="insert into ".$table_name." values(?,?,?,?)"; + $adb->pquery($query, array($userid, $tabid, $reltabid, $user_id)); + $user_arr[]=$user_id; + } + } + } + } + + + } + elseif($enttype=='GROUP') + { + if($pertype =='read') + { + $table_name='vtiger_tmp_read_group_rel_sharing_per'; + $var_name=$module.'_'.$relmodule.'_share_read_permission'; + } + elseif($pertype == 'write') + { + $table_name='vtiger_tmp_write_group_rel_sharing_per'; + $var_name=$module.'_'.$relmodule.'_share_write_permission'; + } + // Lookup for the variable if not set through function argument + if(!$var_name_arr) $var_name_arr=$$var_name; + $grp_arr=Array(); + if(sizeof($var_name_arr['GROUP']) > 0) + { + + foreach($var_name_arr['GROUP'] as $grpid=>$grpusers) + { + if(! in_array($grpid,$grp_arr)) + { + $query="insert into ".$table_name." values(?,?,?,?)"; + $adb->pquery($query, array($userid, $tabid, $reltabid, $grpid)); + $grp_arr[]=$grpid; + } + } + } + + } + +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Users/DefaultDataPopulator.php b/oss/vtiger/trunk/modules/Users/DefaultDataPopulator.php new file mode 100644 index 00000000..371c6ace --- /dev/null +++ b/oss/vtiger/trunk/modules/Users/DefaultDataPopulator.php @@ -0,0 +1,2547 @@ +log = LoggerManager::getLogger('DefaultDataPopulator'); + $this->db = PearDatabase::getInstance(); + } + + var $new_schema = true; + + /** Function to populate the default required data during installation + */ + function create_tables () { + global $app_strings; + + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (3,'Home',0,1,'Home',0,1,0)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (7,'Leads',0,4,'Leads',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (6,'Accounts',0,5,'Accounts',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (4,'Contacts',0,6,'Contacts',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (2,'Potentials',0,7,'Potentials',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (8,'Documents',0,9,'Documents',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (9,'Calendar',0,3,'Calendar',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (10,'Emails',0,10,'Emails',0,1,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (13,'HelpDesk',0,11,'HelpDesk',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (14,'Products',0,8,'Products',0,1,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (1,'Dashboard',0,12,'Dashboards',0,1,0)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (15,'Faq',0,14,'Faq',0,1,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (16,'Events',2,13,'Events',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (18,'Vendors',0,15,'Vendors',0,1,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (19,'PriceBooks',0,16,'PriceBooks',0,1,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (20,'Quotes',0,17,'Quotes',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (21,'PurchaseOrder',0,18,'PurchaseOrder',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (22,'SalesOrder',0,19,'SalesOrder',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (23,'Invoice',0,20,'Invoice',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (24,'Rss',0,21,'Rss',0,1,0)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (25,'Reports',0,22,'Reports',0,1,0)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (26,'Campaigns',0,23,'Campaigns',0,0,1)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (27,'Portal',0,24,'Portal',0,1,0)"); + $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (28,'Webmails',0,25,'Webmails',0,1,1)"); + $this->db->query("insert into vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) values (29,'Users',0,26,'Users',0,1,0)"); + + // Populate the vtiger_blocks vtiger_table + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",2,'LBL_OPPORTUNITY_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",2,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",2,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",4,'LBL_CONTACT_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",4,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",4,'LBL_CUSTOMER_PORTAL_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",4,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",4,'LBL_DESCRIPTION_INFORMATION',5,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",6,'LBL_ACCOUNT_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",6,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",6,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",6,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",7,'LBL_LEAD_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",7,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",7,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",7,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",8,'LBL_NOTE_INFORMATION',1,0,0,0,0,0,1,0)"); + $fileblockid = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$fileblockid.",8,'LBL_FILE_INFORMATION',3,1,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",9,'LBL_TASK_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",9,'',2,1,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",10,'LBL_EMAIL_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",10,'',2,1,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",10,'',3,1,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",10,'',4,1,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",13,'LBL_TICKET_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",13,'',2,1,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",13,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",13,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",13,'LBL_TICKET_RESOLUTION',5,0,0,1,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",13,'LBL_COMMENTS',6,0,0,1,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",14,'LBL_PRODUCT_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",14,'LBL_PRICING_INFORMATION',2,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",14,'LBL_STOCK_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",14,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",14,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",14,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'LBL_FAQ_INFORMATION',1,0,0,0,0,0,1,0)"); + //$this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'',2,1,0,0,0,0,1,0)"); + //$this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'',3,1,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'LBL_COMMENT_INFORMATION',4,0,0,1,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",16,'LBL_EVENT_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",16,'',2,1,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",16,'',3,1,0,0,0,0,1,0)"); + $vendorbasicinfo = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$vendorbasicinfo.",18,'LBL_VENDOR_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",18,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $vendoraddressblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$vendoraddressblock.",18,'LBL_VENDOR_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)"); + $vendordescriptionblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$vendordescriptionblock.",18,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)"); + $pricebookbasicblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$pricebookbasicblock.",19,'LBL_PRICEBOOK_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",19,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $pricebookdescription = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$pricebookdescription.",19,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0,1,0)"); + $quotesbasicblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$quotesbasicblock.",20,'LBL_QUOTE_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",20,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $quotesaddressblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$quotesaddressblock.",20,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",20,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)"); + $quotetermsblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$quotetermsblock.",20,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)"); + $quotedescription = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$quotedescription.",20,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)"); + $pobasicblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$pobasicblock.",21,'LBL_PO_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",21,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $poaddressblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$poaddressblock.",21,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",21,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)"); + $potermsblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$potermsblock.",21,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)"); + $podescription = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$podescription.",21,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)"); + $sobasicblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$sobasicblock .",22,'LBL_SO_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",22,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)"); + $soaddressblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$soaddressblock.",22,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",22,'LBL_RELATED_PRODUCTS',5,0,0,0,0,0,1,0)"); + $sotermsblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$sotermsblock.",22,'LBL_TERMS_INFORMATION',6,0,0,0,0,0,1,0)"); + $sodescription = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$sodescription.",22,'LBL_DESCRIPTION_INFORMATION',7,0,0,0,0,0,1,0)"); + $invoicebasicblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$invoicebasicblock.",23,'LBL_INVOICE_INFORMATION',1,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",23,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $invoiceaddressblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$invoiceaddressblock.",23,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",23,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)"); + $invoicetermsblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$invoicetermsblock.",23,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)"); + $invoicedescription = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$invoicedescription.",23,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)"); + $imageblockid = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$imageblockid.",4,'LBL_IMAGE_INFORMATION',6,0,0,0,0,0,1,0)"); + $campaignbasicblockid = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$campaignbasicblockid.",26,'LBL_CAMPAIGN_INFORMATION',1,0,0,0,0,0,1,0)"); + $campaigncustomblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$campaigncustomblock.",26,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)"); + $campaignexpectedandactualsblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$campaignexpectedandactualsblock.",26,'LBL_EXPECTATIONS_AND_ACTUALS',3,0,0,0,0,0,1,0)"); + $userloginandroleblockid = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$userloginandroleblockid.",29,'LBL_USERLOGIN_ROLE',1,0,0,0,0,0,1,0)"); + $usermoreinfoblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$usermoreinfoblock.",29,'LBL_MORE_INFORMATION',2,0,0,0,0,0,1,0)"); + $useraddressblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$useraddressblock.",29,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)"); + //Added an extra block for new UI Settings in Campaigns module + $campaidndescriptionblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$campaidndescriptionblock.",26,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)"); + $userblockid = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$userblockid.",29,'LBL_USER_IMAGE_INFORMATION',4,0,0,0,0,0,1,0)"); //Added a New Block User Image Info in Users Module + $useradvanceblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$useradvanceblock .",29,'LBL_USER_ADV_OPTIONS',5,0,0,0,0,0,1,0)"); //Added a New Block User Image Info in Users Module + //Added block 'File Information' to Documents module + $desc_blockid = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$desc_blockid.",8,'LBL_DESCRIPTION',2,0,0,0,0,0,1,0)"); + //Added block for storing the Recurring Inovice Informaiton in SalesOrder + $sorecurringinvoiceblock = $this->db->getUniqueID('vtiger_blocks'); + $this->db->query("insert into vtiger_blocks values (".$sorecurringinvoiceblock.",22,'Recurring Invoice Information',2,0,0,0,0,0,1,0)"); + //Added to support custom fields for Calendar + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",9,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)"); + $this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",16,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0,1,0)"); + + //Account Details -- START + //Block9 + + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'accountname','vtiger_account',1,'2','accountname','Account Name',1,0,0,100,1,9,1,'V~M',0,1,'BAS',0)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'account_no','vtiger_account',1,'4','account_no','Account No',1,0,0,100,2,9,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'phone','vtiger_account',1,'11','phone','Phone',1,2,0,100,4,9,1,'V~O',2,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'website','vtiger_account',1,'17','website','Website',1,2,0,100,3,9,1,'V~O',2,3,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'fax','vtiger_account',1,'1','fax','Fax',1,2,0,100,6,9,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'tickersymbol','vtiger_account',1,'1','tickersymbol','Ticker Symbol',1,2,0,100,5,9,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'otherphone','vtiger_account',1,'11','otherphone','Other Phone',1,2,0,100,8,9,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'parentid','vtiger_account',1,'51','account_id','Member Of',1,2,0,100,7,9,1,'I~O',1,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'email1','vtiger_account',1,'13','email1','Email',1,2,0,100,10,9,1,'E~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'employees','vtiger_account',1,'7','employees','Employees',1,2,0,100,9,9,1,'I~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'email2','vtiger_account',1,'13','email2','Other Email',1,2,0,100,11,9,1,'E~O',1,null,'ADV',1)"); + + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ownership','vtiger_account',1,'1','ownership','Ownership',1,2,0,100,12,9,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'rating','vtiger_account',1,'15','rating','Rating',1,2,0,100,14,9,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'industry','vtiger_account',1,'15','industry','industry',1,2,0,100,13,9,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'siccode','vtiger_account',1,'1','siccode','SIC Code',1,2,0,100,16,9,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'account_type','vtiger_account',1,'15','accounttype','Type',1,2,0,100,15,9,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'annualrevenue','vtiger_account',1,'71','annual_revenue','Annual Revenue',1,2,0,100,18,9,1,'I~O',1,null,'ADV',1)"); + //Added vtiger_field emailoptout for vtiger_accounts -- after 4.2 patch2 + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'emailoptout','vtiger_account',1,'56','emailoptout','Email Opt Out',1,2,0,100,17,9,1,'C~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'notify_owner','vtiger_account',1,56,'notify_owner','Notify Owner',1,2,0,10,20,9,1,'C~O',1,NULL,'ADV',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,19,9,1,'V~M',0,4,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,22,9,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,21,9,2,'T~O',3,null,'BAS',0)"); + + //Block 11 + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_accountbillads',1,'21','bill_street','Billing Address',1,2,0,100,1,11,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_accountshipads',1,'21','ship_street','Shipping Address',1,2,0,100,2,11,1,'V~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_accountbillads',1,'1','bill_city','Billing City',1,2,0,100,5,11,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_accountshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,11,1,'V~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_accountbillads',1,'1','bill_state','Billing State',1,2,0,100,7,11,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_accountshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,11,1,'V~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_accountbillads',1,'1','bill_code','Billing Code',1,2,0,100,9,11,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_accountshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,11,1,'V~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_accountbillads',1,'1','bill_country','Billing Country',1,2,0,100,11,11,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_accountshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,11,1,'V~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_accountbillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,11,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_accountshipads',1,'1','ship_pobox','Shipping Po Box',1,2,0,100,4,11,1,'V~O',1,null,'BAS',1)"); + + //Block12 + $this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,12,1,'V~O',1,null,'BAS',1)"); + + //Account Details -- END + + //Lead Details --- START + //Block13 -- Start + + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'salutation','vtiger_leaddetails',1,'55','salutationtype','Salutation',1,0,0,100,1,13,3,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'firstname','vtiger_leaddetails',1,'55','firstname','First Name',1,2,0,100,2,13,1,'V~O',2,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'lead_no','vtiger_leaddetails',1,'4','lead_no','Lead No',1,0,0,100,3,13,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'phone','vtiger_leadaddress',1,'11','phone','Phone',1,2,0,100,5,13,1,'V~O',2,4,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'lastname','vtiger_leaddetails',1,'255','lastname','Last Name',1,0,0,100,4,13,1,'V~M',0,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'mobile','vtiger_leadaddress',1,'1','mobile','Mobile',1,2,0,100,7,13,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'company','vtiger_leaddetails',1,'2','company','Company',1,2,0,100,6,13,1,'V~M',2,3,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'fax','vtiger_leadaddress',1,'1','fax','Fax',1,2,0,100,9,13,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'designation','vtiger_leaddetails',1,'1','designation','Designation',1,2,0,100,8,13,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'email','vtiger_leaddetails',1,'13','email','Email',1,2,0,100,11,13,1,'E~O',2,5,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'leadsource','vtiger_leaddetails',1,'15','leadsource','Lead Source',1,2,0,100,10,13,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'website','vtiger_leadsubdetails',1,'17','website','Website',1,2,0,100,13,13,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'industry','vtiger_leaddetails',1,'15','industry','Industry',1,2,0,100,12,13,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'leadstatus','vtiger_leaddetails',1,'15','leadstatus','Lead Status',1,2,0,100,15,13,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'annualrevenue','vtiger_leaddetails',1,'71','annualrevenue','Annual Revenue',1,2,0,100,14,13,1,'I~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'rating','vtiger_leaddetails',1,'15','rating','Rating',1,2,0,100,17,13,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'noofemployees','vtiger_leaddetails',1,'1','noofemployees','No Of Employees',1,2,0,100,16,13,1,'I~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,19,13,1,'V~M',0,6,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'yahooid','vtiger_leaddetails',1,'13','yahooid','Yahoo Id',1,2,0,100,18,13,1,'E~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,21,13,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,20,13,2,'T~O',3,null,'BAS',0)"); + //Block13 -- End + + //Block15 -- Start + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'lane','vtiger_leadaddress',1,'21','lane','Street',1,2,0,100,1,15,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'code','vtiger_leadaddress',1,'1','code','Postal Code',1,2,0,100,3,15,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'city','vtiger_leadaddress',1,'1','city','City',1,2,0,100,4,15,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'country','vtiger_leadaddress',1,'1','country','Country',1,2,0,100,5,15,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'state','vtiger_leadaddress',1,'1','state','State',1,2,0,100,6,15,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'pobox','vtiger_leadaddress',1,'1','pobox','Po Box',1,2,0,100,2,15,1,'V~O',1,null,'BAS',1)"); + //Block15 --End + + //Block16 -- Start + $this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,16,1,'V~O',1,null,'BAS',1)"); + //Block16 -- End + + //Lead Details -- END + + //Contact Details -- START + //Block4 -- Start + + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'salutation','vtiger_contactdetails',1,'55','salutationtype','Salutation',1,0,0,100,1,4,3,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'firstname','vtiger_contactdetails',1,'55','firstname','First Name',1,2,0,100,2,4,1,'V~O',2,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'contact_no','vtiger_contactdetails',1,'4','contact_no','Contact Id',1,0,0,100,3,4,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'phone','vtiger_contactdetails',1,'11','phone','Office Phone',1,2,0,100,5,4,1,'V~O',2,4,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'lastname','vtiger_contactdetails',1,'255','lastname','Last Name',1,0,0,100,4,4,1,'V~M',0,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mobile','vtiger_contactdetails',1,'1','mobile','Mobile',1,2,0,100,7,4,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'accountid','vtiger_contactdetails',1,'51','account_id','Account Name',1,0,0,100,6,4,1,'I~O',2,3,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'homephone','vtiger_contactsubdetails',1,'11','homephone','Home Phone',1,2,0,100,9,4,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'leadsource','vtiger_contactsubdetails',1,'15','leadsource','Lead Source',1,2,0,100,8,4,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'otherphone','vtiger_contactsubdetails',1,'11','otherphone','Other Phone',1,2,0,100,11,4,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'title','vtiger_contactdetails',1,'1','title','Title',1,2,0,100,10,4,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'fax','vtiger_contactdetails',1,'1','fax','Fax',1,2,0,100,13,4,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'department','vtiger_contactdetails',1,'1','department','Department',1,2,0,100,12,4,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'birthday','vtiger_contactsubdetails',1,'5','birthday','Birthdate',1,2,0,100,16,4,1,'D~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'email','vtiger_contactdetails',1,'13','email','Email',1,2,0,100,15,4,1,'E~O',2,5,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'reportsto','vtiger_contactdetails',1,'57','contact_id','Reports To',1,2,0,100,18,4,1,'V~O',1,null,'ADV',0)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'assistant','vtiger_contactsubdetails',1,'1','assistant','Assistant',1,2,0,100,17,4,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'yahooid','vtiger_contactdetails',1,'13','yahooid','Yahoo Id',1,2,0,100,20,4,1,'E~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'assistantphone','vtiger_contactsubdetails',1,'11','assistantphone','Assistant Phone',1,2,0,100,19,4,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'donotcall','vtiger_contactdetails',1,'56','donotcall','Do Not Call',1,2,0,100,22,4,1,'C~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'emailoptout','vtiger_contactdetails',1,'56','emailoptout','Email Opt Out',1,2,0,100,21,4,1,'C~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,24,4,1,'V~M',0,6,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'reference','vtiger_contactdetails',1,'56','reference','Reference',1,2,0,10,23,4,1,'C~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'notify_owner','vtiger_contactdetails',1,'56','notify_owner','Notify Owner',1,2,0,10,26,4,1,'C~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,25,4,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,27,4,2,'T~O',3,null,'BAS',0)"); + //Block4 -- End + + //Block6 - Begin Customer Portal + + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'portal','vtiger_customerdetails',1,'56','portal','Portal User',1,2,0,100,1,6,1,'C~O',1,null,'ADV',0)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'support_start_date','vtiger_customerdetails',1,'5','support_start_date','Support Start Date',1,2,0,100,2,6,1,'D~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'support_end_date','vtiger_customerdetails',1,'5','support_end_date','Support End Date',1,2,0,100,3,6,1,'D~O~OTH~GE~support_start_date~Support Start Date',1,null,'ADV',1)"); + + //Block6 - End Customer Portal + + //Block 7 -- Start + + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingstreet','vtiger_contactaddress',1,'21','mailingstreet','Mailing Street',1,2,0,100,1,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'otherstreet','vtiger_contactaddress',1,'21','otherstreet','Other Street',1,2,0,100,2,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingcity','vtiger_contactaddress',1,'1','mailingcity','Mailing City',1,2,0,100,5,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'othercity','vtiger_contactaddress',1,'1','othercity','Other City',1,2,0,100,6,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingstate','vtiger_contactaddress',1,'1','mailingstate','Mailing State',1,2,0,100,7,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'otherstate','vtiger_contactaddress',1,'1','otherstate','Other State',1,2,0,100,8,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingzip','vtiger_contactaddress',1,'1','mailingzip','Mailing Zip',1,2,0,100,9,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'otherzip','vtiger_contactaddress',1,'1','otherzip','Other Zip',1,2,0,100,10,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingcountry','vtiger_contactaddress',1,'1','mailingcountry','Mailing Country',1,2,0,100,11,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'othercountry','vtiger_contactaddress',1,'1','othercountry','Other Country',1,2,0,100,12,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingpobox','vtiger_contactaddress',1,'1','mailingpobox','Mailing Po Box',1,2,0,100,3,7,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'otherpobox','vtiger_contactaddress',1,'1','otherpobox','Other Po Box',1,2,0,100,4,7,1,'V~O',1,null,'BAS',1)"); + //Block7 -- End + + //ContactImageInformation + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'imagename','vtiger_contactdetails',1,'69','imagename','Contact Image',1,2,0,100,1,$imageblockid,1,'V~O',3,null,'ADV',0)"); + + + //Block8 -- Start + $this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,8,1,'V~O',1,null,'BAS',1)"); + //Block8 -- End + //Contact Details -- END + + //Potential Details -- START + //Block1 -- Start + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'potentialname','vtiger_potential',1,'2','potentialname','Potential Name',1,0,0,100,1,1,1,'V~M',0,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'potential_no','vtiger_potential',1,'4','potential_no','Potential No',1,0,0,100,2,1,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'amount','vtiger_potential',1,71,'amount','Amount',1,2,0,100,4,1,1,'N~O',2,5,'BAS',1)"); + //changed for b2c model + $fieldid = $this->db->getUniqueID("vtiger_field"); + $this->db->query("insert into vtiger_field values (2,$fieldid,'related_to','vtiger_potential',1,'10','related_to','Related To',1,0,0,100,3,1,1,'V~M',0,2,'BAS',1)"); + $this->db->query("insert into vtiger_fieldmodulerel (fieldid, module, relmodule, status, sequence) values ($fieldid, 'Potentials', 'Accounts', NULL, 0), ($fieldid, 'Potentials', 'Contacts', NULL, 1)"); + //b2c model changes end + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'closingdate','vtiger_potential',1,'23','closingdate','Expected Close Date',1,2,0,100,7,1,1,'D~M',2,3,'BAS',1)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'potentialtype','vtiger_potential',1,'15','opportunity_type','Type',1,2,0,100,6,1,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'nextstep','vtiger_potential',1,'1','nextstep','Next Step',1,2,0,100,9,1,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'leadsource','vtiger_potential',1,'15','leadsource','Lead Source',1,2,0,100,8,1,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'sales_stage','vtiger_potential',1,'15','sales_stage','Sales Stage',1,2,0,100,11,1,1,'V~M',2,4,'BAS',1)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,2,0,100,10,1,1,'V~M',0,6,'BAS',1)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'probability','vtiger_potential',1,'9','probability','Probability',1,2,0,100,13,1,1,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'campaignid','vtiger_potential',1,'58','campaignid','Campaign Source',1,2,0,100,12,1,1,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,15,1,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,14,1,2,'T~O',3,null,'BAS',0)"); + + //Block1 -- End + + //Block3 -- Start + $this->db->query("insert into vtiger_field values (2,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,3,1,'V~O',1,null,'BAS',1)"); + //Block3 -- End + //Potential Details -- END + + //campaign entries being added + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'campaignname','vtiger_campaign',1,'2','campaignname','Campaign Name',1,0,0,100,1,$campaignbasicblockid,1,'V~M',0,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'campaign_no','vtiger_campaign',1,'4','campaign_no','Campaign No',1,0,0,100,2,$campaignbasicblockid,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'campaigntype','vtiger_campaign',1,15,'campaigntype','Campaign Type',1,2,0,100,5,$campaignbasicblockid,1,'V~O',2,3,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'product_id','vtiger_campaign',1,59,'product_id','Product',1,2,0,100,6,$campaignbasicblockid,1,'I~O',2,5,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'campaignstatus','vtiger_campaign',1,15,'campaignstatus','Campaign Status',1,2,0,100,4,$campaignbasicblockid,1,'V~O',2,6,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'closingdate','vtiger_campaign',1,'23','closingdate','Expected Close Date',1,2,0,100,8,$campaignbasicblockid,1,'D~M',2,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,3,$campaignbasicblockid,1,'V~M',0,7,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'numsent','vtiger_campaign',1,'9','numsent','Num Sent',1,2,0,100,12,$campaignbasicblockid,1,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'sponsor','vtiger_campaign',1,'1','sponsor','Sponsor',1,2,0,100,9,$campaignbasicblockid,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'targetaudience','vtiger_campaign',1,'1','targetaudience','Target Audience',1,2,0,100,7,$campaignbasicblockid,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("vtiger_field").",'targetsize','vtiger_campaign',1,'1','targetsize','TargetSize',1,2,0,100,10,$campaignbasicblockid,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,11,$campaignbasicblockid,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,13,$campaignbasicblockid,2,'T~O',3,null,'BAS',0)"); + + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'expectedresponse','vtiger_campaign',1,'15','expectedresponse','Expected Response',1,2,0,100,3,$campaignexpectedandactualsblock,1,'V~O',2,4,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'expectedrevenue','vtiger_campaign',1,'1','expectedrevenue','Expected Revenue',1,2,0,100,4,$campaignexpectedandactualsblock,1,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'budgetcost','vtiger_campaign',1,'1','budgetcost','Budget Cost',1,2,0,100,1,$campaignexpectedandactualsblock,1,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'actualcost','vtiger_campaign',1,'1','actualcost','Actual Cost',1,2,0,100,2,$campaignexpectedandactualsblock,1,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("vtiger_field").",'expectedresponsecount','vtiger_campaign',1,'1','expectedresponsecount','Expected Response Count',1,2,0,100,7,$campaignexpectedandactualsblock,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("vtiger_field").",'expectedsalescount','vtiger_campaign',1,'1','expectedsalescount','Expected Sales Count',1,2,0,100,5,$campaignexpectedandactualsblock,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("vtiger_field").",'expectedroi','vtiger_campaign',1,'1','expectedroi','Expected ROI',1,2,0,100,9,$campaignexpectedandactualsblock,1,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("vtiger_field").",'actualresponsecount','vtiger_campaign',1,'1','actualresponsecount','Actual Response Count',1,2,0,100,8,$campaignexpectedandactualsblock,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("vtiger_field").",'actualsalescount','vtiger_campaign',1,'1','actualsalescount','Actual Sales Count',1,2,0,100,6,$campaignexpectedandactualsblock,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values(26,".$this->db->getUniqueID("vtiger_field").",'actualroi','vtiger_campaign',1,'1','actualroi','Actual ROI',1,2,0,100,10,$campaignexpectedandactualsblock,1,'N~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (26,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,$campaidndescriptionblock,1,'V~O',1,null,'BAS',1)"); + + //entry to vtiger_field to maintain account,contact,lead relationships + + $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, selected, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (".getTabid('Contacts').",".$this->db->getUniqueID('vtiger_field').", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)"); + $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, selected, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (".getTabid('Accounts').",".$this->db->getUniqueID('vtiger_field').", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)"); + $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, selected, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (".getTabid('Leads').",".$this->db->getUniqueID('vtiger_field').", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)"); + $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, selected, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (".getTabid('Campaigns').",".$this->db->getUniqueID('vtiger_field').", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)"); + //Campaign entries end + + //Ticket Details -- START + //Block25 -- Start + + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'ticket_no','vtiger_troubletickets',1,'4','ticket_no','Ticket No',1,0,0,100,13,25,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,4,25,1,'V~M',0,4,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'parent_id','vtiger_troubletickets',1,'68','parent_id','Related To',1,0,0,100,2,25,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'priority','vtiger_troubletickets',1,'15','ticketpriorities','Priority',1,2,0,100,6,25,1,'V~O',2,3,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'product_id','vtiger_troubletickets',1,'59','product_id','Product Name',1,2,0,100,5,25,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'severity','vtiger_troubletickets',1,'15','ticketseverities','Severity',1,2,0,100,8,25,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'status','vtiger_troubletickets',1,'15','ticketstatus','Status',1,2,0,100,7,25,1,'V~M',1,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'category','vtiger_troubletickets',1,'15','ticketcategories','Category',1,2,0,100,10,25,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'update_log','vtiger_troubletickets',1,'19','update_log','Update History',1,0,0,100,11,25,3,'V~O',1,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'hours','vtiger_troubletickets',1,'1','hours','Hours',1,2,0,100,9,25,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'days','vtiger_troubletickets',1,'1','days','Days',1,2,0,100,10,25,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,9,25,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,12,25,2,'T~O',3,null,'BAS',0)"); + + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'title','vtiger_troubletickets',1,'22','ticket_title','Title',1,0,0,100,1,25,1,'V~M',0,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,28,1,'V~O',2,4,'BAS',1)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'solution','vtiger_troubletickets',1,'19','solution','Solution',1,0,0,100,1,29,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (13,".$this->db->getUniqueID("vtiger_field").",'comments','vtiger_ticketcomments',1,'19','comments','Add Comment',1,0,0,100,1,30,1,'V~O',3,null,'BAS',0)"); + + //Block25-30 -- End + //Ticket Details -- END + + //Product Details -- START + //Block31-36 -- Start + + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productname','vtiger_products',1,'2','productname','Product Name',1,0,0,100,1,31,1,'V~M',0,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'product_no','vtiger_products',1,'4','product_no','Product No',1,0,0,100,2,31,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productcode','vtiger_products',1,'1','productcode','Part Number',1,2,0,100,4,31,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'discontinued','vtiger_products',1,'56','discontinued','Product Active',1,2,0,100,3,31,1,'V~O',2,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'manufacturer','vtiger_products',1,'15','manufacturer','Manufacturer',1,2,0,100,6,31,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productcategory','vtiger_products',1,'15','productcategory','Product Category',1,2,0,100,6,31,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'sales_start_date','vtiger_products',1,'5','sales_start_date','Sales Start Date',1,2,0,100,5,31,1,'D~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'sales_end_date','vtiger_products',1,'5','sales_end_date','Sales End Date',1,2,0,100,8,31,1,'D~O~OTH~GE~sales_start_date~Sales Start Date',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'start_date','vtiger_products',1,'5','start_date','Support Start Date',1,2,0,100,7,31,1,'D~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'expiry_date','vtiger_products',1,'5','expiry_date','Support Expiry Date',1,2,0,100,10,31,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS',1)"); + + + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'website','vtiger_products',1,'17','website','Website',1,2,0,100,14,31,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'vendor_id','vtiger_products',1,'75','vendor_id','Vendor Name',1,2,0,100,13,31,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'mfr_part_no','vtiger_products',1,'1','mfr_part_no','Mfr PartNo',1,2,0,100,16,31,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'vendor_part_no','vtiger_products',1,'1','vendor_part_no','Vendor PartNo',1,2,0,100,15,31,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'serialno','vtiger_products',1,'1','serial_no','Serial No',1,2,0,100,18,31,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productsheet','vtiger_products',1,'1','productsheet','Product Sheet',1,2,0,100,17,31,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'glacct','vtiger_products',1,'15','glacct','GL Account',1,2,0,100,20,31,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,19,31,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,21,31,2,'T~O',3,null,'BAS',0)"); + + + //Block32 Pricing Information + + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'unit_price','vtiger_products',1,'71','unit_price','Unit Price',1,2,0,100,1,32,1,'N~O',2,3,'BAS',0)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'commissionrate','vtiger_products',1,'9','commissionrate','Commission Rate',1,2,0,100,2,32,1,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'taxclass','vtiger_products',1,'83','taxclass','Tax Class',1,2,0,100,4,32,1,'V~O',3,null,'BAS',1)"); + + + //Block 33 stock info + + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'usageunit','vtiger_products',1,'15','usageunit','Usage Unit',1,2,0,100,1,33,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'qty_per_unit','vtiger_products',1,'1','qty_per_unit','Qty/Unit',1,2,0,100,2,33,1,'N~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'qtyinstock','vtiger_products',1,'1','qtyinstock','Qty In Stock',1,2,0,100,3,33,1,'NN~O',0,4,'ADV',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'reorderlevel','vtiger_products',1,'1','reorderlevel','Reorder Level',1,2,0,100,4,33,1,'I~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'handler','vtiger_products',1,'52','assigned_user_id','Handler',1,0,0,100,5,33,1,'I~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'qtyindemand','vtiger_products',1,'1','qtyindemand','Qty In Demand',1,2,0,100,6,33,1,'I~O',1,null,'ADV',1)"); + + //ProductImageInformation + + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'imagename','vtiger_products',1,'69','imagename','Product Image',1,2,0,100,1,35,1,'V~O',3,null,'ADV',1)"); + + //Block 36 Description Info + $this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,36,1,'V~O',1,null,'BAS',1)"); + + //Product Details -- END + + //Documents Details -- START + //Block17 -- Start + + $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("vtiger_field").",'title','vtiger_notes',1,'2','notes_title','Title',1,0,0,100,1,17,1,'V~M',0,1,'BAS',0)"); + $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,5,17,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,6,17,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("vtiger_field").",'filename','vtiger_notes',1,'28','filename','File Name',1,2,0,100,3,".$fileblockid.",1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,4,17,1,'V~M',0,3,'BAS',0)"); + $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("vtiger_field").",'notecontent','vtiger_notes',1,'19','notecontent','Note',1,2,0,100,1,$desc_blockid,1,'V~O',1,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values(8,".$this->db->getUniqueID("vtiger_field").",'filetype','vtiger_notes',1,1,'filetype','File Type',1,2,0,100,5,".$fileblockid.",2,'V~O',3,'','BAS',0)"); + $this->db->query("insert into vtiger_field values(8,".$this->db->getUniqueID("vtiger_field").",'filesize','vtiger_notes',1,1,'filesize','File Size',1,2,0,100,4,".$fileblockid.",2,'I~O',3,'','BAS',0)"); + $this->db->query("insert into vtiger_field values(8,".$this->db->getUniqueID("vtiger_field").",'filelocationtype','vtiger_notes',1,27,'filelocationtype','Download Type',1,0,0,100,1,".$fileblockid.",1,'V~O',3,'','BAS',0)"); + $this->db->query("insert into vtiger_field values(8,".$this->db->getUniqueID("vtiger_field").",'fileversion','vtiger_notes',1,1,'fileversion','Version',1,2,0,100,6,$fileblockid,1,'V~O',1,'','BAS',0)"); + $this->db->query("insert into vtiger_field values(8,".$this->db->getUniqueID("vtiger_field").",'filestatus','vtiger_notes',1,56,'filestatus','Active',1,2,0,100,2,".$fileblockid.",1,'V~O',1,'','BAS',0)"); + $this->db->query("insert into vtiger_field values(8,".$this->db->getUniqueID("vtiger_field").",'filedownloadcount','vtiger_notes',1,1,'filedownloadcount','Download Count',1,2,0,100,7,".$fileblockid.",2,'I~O',3,'','BAS',0)"); + $this->db->query("insert into vtiger_field values(8,".$this->db->getUniqueID("vtiger_field").",'folderid','vtiger_notes',1,26,'folderid','Folder Name',1,2,0,100,2,17,1,'V~O',2,2,'BAS',0)"); + + $this->db->query("insert into vtiger_field values (8,".$this->db->getUniqueID("vtiger_field").",'note_no','vtiger_notes',1,'4','note_no','Document No',1,0,0,100,3,17,1,'V~O',3,null,'BAS',0)"); + + //Block17 -- End + //Documents Details -- END + + //Email Details -- START + //Block21 -- Start + + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'date_start','vtiger_activity',1,'6','date_start','Date & Time Sent',1,0,0,100,1,21,1,'DT~M~time_start~Time Start',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'semodule','vtiger_activity',1,'2','parent_type','Sales Enity Module',1,0,0,100,2,21,3,'',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'activitytype','vtiger_activity',1,'2','activitytype','Activtiy Type',1,0,0,100,3,21,3,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,5,21,1,'V~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'subject','vtiger_activity',1,'2','subject','Subject',1,0,0,100,1,23,1,'V~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'name','vtiger_attachments',1,'61','filename','Attachment',1,0,0,100,2,23,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,24,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,0,100,9,23,1,'T~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,10,22,1,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (10,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,11,21,2,'T~O',3,null,'BAS',0)"); + $this->db->query("INSERT INTO vtiger_field VALUES (10,".$this->db->getUniqueID("vtiger_field").", 'access_count', 'vtiger_email_track', '1', '25', 'access_count', 'Access Count', '1', '0', '0', '100', '6', '21', '3', 'V~O', '1', NULL, 'BAS', 0)"); + + //Block21 -- End + //Email Details -- END + + //Task Details --START + //Block19 -- Start + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'subject','vtiger_activity',1,'2','subject','Subject',1,0,0,100,1,19,1,'V~M',0,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,19,1,'V~M',0,4,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,0,100,3,19,1,'DT~M~time_start',0,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,0,100,4,19,3,'T~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'time_end','vtiger_activity',1,'2','time_end','End Time',1,0,0,100,4,19,3,'T~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'due_date','vtiger_activity',1,'23','due_date','Due Date',1,0,0,100,5,19,1,'D~M~OTH~GE~date_start~Start Date & Time',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,0,100,7,19,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,0,100,8,19,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'status','vtiger_activity',1,'15','taskstatus','Status',1,0,0,100,8,19,1,'V~M',0,3,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,0,100,9,19,3,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'priority','vtiger_activity',1,'15','taskpriority','Priority',1,0,0,100,10,19,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,0,100,11,19,1,'C~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,14,19,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,15,19,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,0,100,16,19,3,'V~O',1,null,'BAS',1)"); + $this->db->query("Insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'visibility','vtiger_activity',1,'16','visibility','Visibility',1,0,0,100,17,19,3,'V~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,20,1,'V~O',1,null,'BAS',1)"); + + + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,0,100,17,19,3,'T~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'duration_minutes','vtiger_activity',1,'16','duration_minutes','Duration Minutes',1,0,0,100,18,19,3,'T~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'location','vtiger_activity',1,'1','location','Location',1,0,0,100,19,19,3,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,0,100,1,19,3,'I~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'recurringtype','vtiger_activity',1,'16','recurringtype','Recurrence',1,0,0,100,6,19,3,'O~O',1,null,'BAS',1)"); + + $this->db->query("Insert into vtiger_field values (9,".$this->db->getUniqueID("vtiger_field").",'notime','vtiger_activity',1,56,'notime','No Time',1,0,0,100,20,19,3,'C~O',1,null,'BAS',1)"); + //Block19 -- End + //Task Details -- END + + //Event Details --START + //Block41-43-- Start + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'subject','vtiger_activity',1,'2','subject','Subject',1,0,0,100,1,41,1,'V~M',0,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,41,1,'V~M',0,6,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,0,100,3,41,1,'DT~M~time_start',0,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,0,100,4,41,3,'T~M',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'due_date','vtiger_activity',1,'23','due_date','End Date',1,0,0,100,5,41,1,'D~M~OTH~GE~date_start~Start Date & Time',0,5,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'time_end','vtiger_activity',1,'2','time_end','End Time',1,0,0,100,5,41,3,'T~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'recurringtype','vtiger_activity',1,'16','recurringtype','Recurrence',1,0,0,100,6,41,1,'O~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,0,100,7,41,1,'I~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'duration_minutes','vtiger_activity',1,'16','duration_minutes','Duration Minutes',1,0,0,100,8,41,3,'O~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,0,100,9,41,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,0,100,10,41,1,'V~M',0,3,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,0,100,11,41,1,'C~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,0,100,12,41,1,'V~M',0,4,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'location','vtiger_activity',1,'1','location','Location',1,0,0,100,13,41,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,14,41,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,15,41,2,'T~O',3,null,'BAS',0)"); + $this->db->query("Insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'priority','vtiger_activity',1,15,'taskpriority','Priority',1,0,0,100,16,41,1,'V~O',1,null,'BAS',1)"); + $this->db->query("Insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'notime','vtiger_activity',1,56,'notime','No Time',1,0,0,100,17,41,1,'C~O',1,null,'BAS',1)"); + $this->db->query("Insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'visibility','vtiger_activity',1,'16','visibility','Visibility',1,0,0,100,18,41,1,'V~O',1,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,41,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,0,100,1,40,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (16,".$this->db->getUniqueID("vtiger_field").",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,0,100,1,19,1,'I~O',1,null,'BAS',1)"); + + //Block41-43 -- End + //Event Details -- END + + //Faq Details -- START + //Block37-40 -- Start + + $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("vtiger_field").",'product_id','vtiger_faq',1,'59','product_id','Product Name',1,2,0,100,1,37,1,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("vtiger_field").",'faq_no','vtiger_faq',1,'4','faq_no','Faq No',1,0,0,100,2,37,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("vtiger_field").",'category','vtiger_faq',1,'15','faqcategories','Category',1,2,0,100,4,37,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("vtiger_field").",'status','vtiger_faq',1,'15','faqstatus','Status',1,2,0,100,3,37,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("vtiger_field").",'question','vtiger_faq',1,'20','question','Question',1,2,0,100,7,37,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("vtiger_field").",'answer','vtiger_faq',1,'20','faq_answer','Answer',1,2,0,100,8,37,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("vtiger_field").",'comments','vtiger_faqcomments',1,'19','comments','Add Comment',1,0,0,100,1,38,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,5,37,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (15,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,6,37,2,'T~O',3,null,'BAS',0)"); + + + //Block37-40 -- End + //Ticket Details -- END + + //Vendor Details --START + //Block44-47 + + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'vendorname','vtiger_vendor',1,'2','vendorname','Vendor Name',1,0,0,100,1,$vendorbasicinfo,1,'V~M',0,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'vendor_no','vtiger_vendor',1,'4','vendor_no','Vendor No',1,0,0,100,2,$vendorbasicinfo,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'phone','vtiger_vendor',1,'1','phone','Phone',1,2,0,100,4,$vendorbasicinfo,1,'V~O',2,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'email','vtiger_vendor',1,'13','email','Email',1,2,0,100,3,$vendorbasicinfo,1,'E~O',2,3,'BAS',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'website','vtiger_vendor',1,'17','website','Website',1,2,0,100,6,$vendorbasicinfo,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'glacct','vtiger_vendor',1,'15','glacct','GL Account',1,2,0,100,5,$vendorbasicinfo,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'category','vtiger_vendor',1,'1','category','Category',1,2,0,100,8,$vendorbasicinfo,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,7,$vendorbasicinfo,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,9,$vendorbasicinfo,2,'T~O',3,null,'BAS',0)"); + + //Block 46 + + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'street','vtiger_vendor',1,'21','street','Street',1,2,0,100,1,$vendoraddressblock,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'pobox','vtiger_vendor',1,'1','pobox','Po Box',1,2,0,100,2,$vendoraddressblock,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'city','vtiger_vendor',1,'1','city','City',1,2,0,100,3,$vendoraddressblock,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'state','vtiger_vendor',1,'1','state','State',1,2,0,100,4,$vendoraddressblock,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'postalcode','vtiger_vendor',1,'1','postalcode','Postal Code',1,2,0,100,5,$vendoraddressblock,1,'V~O',1,null,'ADV',1)"); + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'country','vtiger_vendor',1,'1','country','Country',1,2,0,100,6,$vendoraddressblock,1,'V~O',1,null,'ADV',1)"); + + //Block 47 + + $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,$vendordescriptionblock,1,'V~O',1,null,'ADV',1)"); + + //Vendor Details -- END + + //PriceBook Details Start + //Block48 + + $this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("vtiger_field").",'bookname','vtiger_pricebook',1,'2','bookname','Price Book Name',1,0,0,100,1,$pricebookbasicblock,1,'V~M',0,1,'BAS',1)"); + $this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("vtiger_field").",'pricebook_no','vtiger_pricebook',1,'4','pricebook_no','PriceBook No',1,0,0,100,3,$pricebookbasicblock,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("vtiger_field").",'active','vtiger_pricebook',1,'56','active','Active',1,2,0,100,2,$pricebookbasicblock,1,'C~O',2,2,'BAS',1)"); + $this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,4,$pricebookbasicblock,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,5,$pricebookbasicblock,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("vtiger_field").",'currency_id','vtiger_pricebook',1,'117','currency_id','Currency',1,0,0,100,5,$pricebookbasicblock,1,'I~M',0,3,'BAS',0)"); + //Block50 + + $this->db->query("insert into vtiger_field values (19,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,$pricebookdescription,1,'V~O',1,null,'BAS',1)"); + + //PriceBook Details End + + + //Quote Details -- START + //Block51 + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'quote_no','vtiger_quotes',1,'4','quote_no','Quote No',1,0,0,100,3,$quotesbasicblock,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'subject','vtiger_quotes',1,'2','subject','Subject',1,0,0,100,1,$quotesbasicblock,1,'V~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'potentialid','vtiger_quotes',1,'76','potential_id','Potential Name',1,2,0,100,2,$quotesbasicblock,1,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'quotestage','vtiger_quotes',1,'15','quotestage','Quote Stage',1,2,0,100,4,$quotesbasicblock,1,'V~M',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'validtill','vtiger_quotes',1,'5','validtill','Valid Till',1,2,0,100,5,$quotesbasicblock,1,'D~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'contactid','vtiger_quotes',1,'57','contact_id','Contact Name',1,2,0,100,6,$quotesbasicblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'carrier','vtiger_quotes',1,'15','carrier','Carrier',1,2,0,100,8,$quotesbasicblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'subtotal','vtiger_quotes',1,'1','hdnSubTotal','Sub Total',1,2,0,100,9,$quotesbasicblock,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'shipping','vtiger_quotes',1,'1','shipping','Shipping',1,2,0,100,10,$quotesbasicblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'inventorymanager','vtiger_quotes',1,'77','assigned_user_id1','Inventory Manager',1,2,0,100,11,$quotesbasicblock,1,'I~O',3,null,'BAS',1)"); + //$this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'tax','vtiger_quotes',1,'1','txtTax','Sales Tax',1,0,0,100,13,51,3,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'adjustment','vtiger_quotes',1,'1','txtAdjustment','Adjustment',1,2,0,100,20,$quotesbasicblock,3,'NN~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'total','vtiger_quotes',1,'1','hdnGrandTotal','Total',1,2,0,100,14,$quotesbasicblock,3,'N~O',3,null,'BAS',1)"); + //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'taxtype','vtiger_quotes',1,'16','hdnTaxType','Tax Type',1,2,0,100,14,$quotesbasicblock,3,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'discount_percent','vtiger_quotes',1,'1','hdnDiscountPercent','Discount Percent',1,2,0,100,14,$quotesbasicblock,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'discount_amount','vtiger_quotes',1,'1','hdnDiscountAmount','Discount Amount',1,2,0,100,14,$quotesbasicblock,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'s_h_amount','vtiger_quotes',1,'1','hdnS_H_Amount','S&H Amount',1,2,0,100,14,$quotesbasicblock,3,'N~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'accountid','vtiger_quotes',1,'73','account_id','Account Name',1,2,0,100,16,$quotesbasicblock,1,'I~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,$quotesbasicblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,18,$quotesbasicblock,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,19,$quotesbasicblock,2,'T~O',3,null,'BAS',0)"); + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'currency_id','vtiger_quotes',1,'117','currency_id','Currency',1,2,1,100,20,$quotesbasicblock,3,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'conversion_rate','vtiger_quotes',1,'1','conversion_rate','Conversion Rate',1,2,1,100,21,$quotesbasicblock,3,'N~O',3,null,'BAS',1)"); + + //Block 53 + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_quotesbillads',1,'24','bill_street','Billing Address',1,2,0,100,1,$quotesaddressblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_quotesshipads',1,'24','ship_street','Shipping Address',1,2,0,100,2,$quotesaddressblock,1,'V~M',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_quotesbillads',1,'1','bill_city','Billing City',1,2,0,100,5,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_quotesshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_quotesbillads',1,'1','bill_state','Billing State',1,2,0,100,7,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_quotesshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_quotesbillads',1,'1','bill_code','Billing Code',1,2,0,100,9,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_quotesshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_quotesbillads',1,'1','bill_country','Billing Country',1,2,0,100,11,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_quotesshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_quotesbillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_quotesshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,$quotesaddressblock,1,'V~O',3,null,'BAS',1)"); + //Block55 + + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,$quotedescription,1,'V~O',3,null,'ADV',1)"); + + //Block 56 + $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'terms_conditions','vtiger_quotes',1,'19','terms_conditions','Terms & Conditions',1,2,0,100,1,$quotetermsblock,1,'V~O',3,null,'ADV',1)"); + + + //Quote Details -- END + + //Purchase Order Details -- START + //Block57 + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'purchaseorder_no','vtiger_purchaseorder',1,'4','purchaseorder_no','PurchaseOrder No',1,0,0,100,2,$pobasicblock,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'subject','vtiger_purchaseorder',1,'2','subject','Subject',1,0,0,100,1,$pobasicblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'vendorid','vtiger_purchaseorder',1,'81','vendor_id','Vendor Name',1,0,0,100,3,$pobasicblock,1,'I~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'requisition_no','vtiger_purchaseorder',1,'1','requisition_no','Requisition No',1,2,0,100,4,$pobasicblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'tracking_no','vtiger_purchaseorder',1,'1','tracking_no','Tracking Number',1,2,0,100,5,$pobasicblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'contactid','vtiger_purchaseorder',1,'57','contact_id','Contact Name',1,2,0,100,6,$pobasicblock,1,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'duedate','vtiger_purchaseorder',1,'5','duedate','Due Date',1,2,0,100,7,$pobasicblock,1,'D~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'carrier','vtiger_purchaseorder',1,'15','carrier','Carrier',1,2,0,100,8,$pobasicblock,1,'V~O',3,null,'BAS',1)"); + //$this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_purchaseorder',1,'1','txtTax','Sales Tax',1,0,0,100,10,57,3,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'adjustment','vtiger_purchaseorder',1,'1','txtAdjustment','Adjustment',1,2,0,100,10,$pobasicblock,3,'NN~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'salescommission','vtiger_purchaseorder',1,'1','salescommission','Sales Commission',1,2,0,100,11,$pobasicblock,1,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'exciseduty','vtiger_purchaseorder',1,'1','exciseduty','Excise Duty',1,2,0,100,12,$pobasicblock,1,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'total','vtiger_purchaseorder',1,'1','hdnGrandTotal','Total',1,2,0,100,13,$pobasicblock,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'subtotal','vtiger_purchaseorder',1,'1','hdnSubTotal','Sub Total',1,2,0,100,14,$pobasicblock,3,'N~O',3,null,'BAS',1)"); + //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'taxtype','vtiger_purchaseorder',1,'16','hdnTaxType','Tax Type',1,2,0,100,14,$pobasicblock,3,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'discount_percent','vtiger_purchaseorder',1,'1','hdnDiscountPercent','Discount Percent',1,2,0,100,14,$pobasicblock,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'discount_amount','vtiger_purchaseorder',1,'1','hdnDiscountAmount','Discount Amount',1,0,0,100,14,$pobasicblock,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'s_h_amount','vtiger_purchaseorder',1,'1','hdnS_H_Amount','S&H Amount',1,2,0,100,14,$pobasicblock,3,'N~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'postatus','vtiger_purchaseorder',1,'15','postatus','Status',1,2,0,100,15,$pobasicblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,16,$pobasicblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,17,$pobasicblock,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,18,$pobasicblock,2,'T~O',3,null,'BAS',0)"); + + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'currency_id','vtiger_purchaseorder',1,'117','currency_id','Currency',1,2,1,100,19,$pobasicblock,3,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'conversion_rate','vtiger_purchaseorder',1,'1','conversion_rate','Conversion Rate',1,2,1,100,20,$pobasicblock,3,'N~O',3,null,'BAS',1)"); + + //Block 59 + + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_pobillads',1,'24','bill_street','Billing Address',1,2,0,100,1,$poaddressblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_poshipads',1,'24','ship_street','Shipping Address',1,2,0,100,2,$poaddressblock,1,'V~M',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_pobillads',1,'1','bill_city','Billing City',1,2,0,100,5,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_poshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_pobillads',1,'1','bill_state','Billing State',1,2,0,100,7,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_poshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_pobillads',1,'1','bill_code','Billing Code',1,2,0,100,9,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_poshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + + + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_pobillads',1,'1','bill_country','Billing Country',1,2,0,100,11,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_poshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_pobillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_poshipads',1,'1','ship_pobox','Shipping Po Box',1,2,0,100,4,$poaddressblock,1,'V~O',3,null,'BAS',1)"); + + //Block61 + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,$podescription,1,'V~O',3,null,'ADV',1)"); + + //Block62 + $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'terms_conditions','vtiger_purchaseorder',1,'19','terms_conditions','Terms & Conditions',1,2,0,100,1,$potermsblock,1,'V~O',3,null,'ADV',1)"); + + //Purchase Order Details -- END + + //Sales Order Details -- START + //Block63 + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'salesorder_no','vtiger_salesorder',1,'4','salesorder_no','SalesOrder No',1,0,0,100,4,$sobasicblock ,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'subject','vtiger_salesorder',1,'2','subject','Subject',1,0,0,100,1,$sobasicblock ,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'potentialid','vtiger_salesorder',1,'76','potential_id','Potential Name',1,2,0,100,2,$sobasicblock ,1,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'customerno','vtiger_salesorder',1,'1','customerno','Customer No',1,2,0,100,3,$sobasicblock ,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'quoteid','vtiger_salesorder',1,'78','quote_id','Quote Name',1,2,0,100,5,$sobasicblock ,1,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'purchaseorder','vtiger_salesorder',1,'1','vtiger_purchaseorder','Purchase Order',1,2,0,100,5,$sobasicblock ,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'contactid','vtiger_salesorder',1,'57','contact_id','Contact Name',1,2,0,100,6,$sobasicblock ,1,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'duedate','vtiger_salesorder',1,'5','duedate','Due Date',1,2,0,100,8,$sobasicblock ,1,'D~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'carrier','vtiger_salesorder',1,'15','carrier','Carrier',1,2,0,100,9,$sobasicblock ,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'pending','vtiger_salesorder',1,'1','pending','Pending',1,2,0,100,10,$sobasicblock ,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'sostatus','vtiger_salesorder',1,'15','sostatus','Status',1,2,0,100,11,$sobasicblock ,1,'V~M',3,null,'BAS',1)"); + //$this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_salesorder',1,'1','txtTax','Sales Tax',1,0,0,100,12,63,3,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'adjustment','vtiger_salesorder',1,'1','txtAdjustment','Adjustment',1,2,0,100,12,$sobasicblock ,3,'NN~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'salescommission','vtiger_salesorder',1,'1','salescommission','Sales Commission',1,2,0,100,13,$sobasicblock ,1,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'exciseduty','vtiger_salesorder',1,'1','exciseduty','Excise Duty',1,2,0,100,13,$sobasicblock ,1,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'total','vtiger_salesorder',1,'1','hdnGrandTotal','Total',1,2,0,100,14,$sobasicblock ,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'subtotal','vtiger_salesorder',1,'1','hdnSubTotal','Sub Total',1,2,0,100,15,$sobasicblock ,3,'N~O',3,null,'BAS',1)"); + //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'taxtype','vtiger_salesorder',1,'16','hdnTaxType','Tax Type',1,2,0,100,15,$sobasicblock ,3,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'discount_percent','vtiger_salesorder',1,'1','hdnDiscountPercent','Discount Percent',1,2,0,100,15,$sobasicblock ,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'discount_amount','vtiger_salesorder',1,'1','hdnDiscountAmount','Discount Amount',1,0,0,100,15,$sobasicblock ,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'s_h_amount','vtiger_salesorder',1,'1','hdnS_H_Amount','S&H Amount',1,2,0,100,15,$sobasicblock ,3,'N~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'accountid','vtiger_salesorder',1,'73','account_id','Account Name',1,2,0,100,16,$sobasicblock ,1,'I~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,$sobasicblock ,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,18,$sobasicblock ,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,19,$sobasicblock ,2,'T~O',3,null,'BAS',0)"); + + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'currency_id','vtiger_salesorder',1,'117','currency_id','Currency',1,2,1,100,20,$sobasicblock ,3,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'conversion_rate','vtiger_salesorder',1,'1','conversion_rate','Conversion Rate',1,2,1,100,21,$sobasicblock ,3,'N~O',3,null,'BAS',1)"); + + + //Block 65 + + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_sobillads',1,'24','bill_street','Billing Address',1,2,0,100,1,$soaddressblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_soshipads',1,'24','ship_street','Shipping Address',1,2,0,100,2,$soaddressblock,1,'V~M',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_sobillads',1,'1','bill_city','Billing City',1,2,0,100,5,$soaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_soshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,$soaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_sobillads',1,'1','bill_state','Billing State',1,2,0,100,7,$soaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_soshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,$soaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_sobillads',1,'1','bill_code','Billing Code',1,2,0,100,9,$soaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_soshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,$soaddressblock,1,'V~O',3,null,'BAS',1)"); + + + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_sobillads',1,'1','bill_country','Billing Country',1,2,0,100,11,$soaddressblock,3,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_soshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,$soaddressblock,3,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_sobillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,$soaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_soshipads',1,'1','ship_pobox','Shipping Po Box',1,2,0,100,4,$soaddressblock,1,'V~O',3,null,'BAS',1)"); + + //Block67 + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,$sodescription,1,'V~O',3,null,'ADV',1)"); + + //Block68 + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'terms_conditions','vtiger_salesorder',1,'19','terms_conditions','Terms & Conditions',1,2,0,100,1,$sotermsblock,1,'V~O',3,null,'ADV',1)"); + + // Add fields for the Recurring Information block - Block 86 + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID('vtiger_field').",'enable_recurring','vtiger_salesorder',1,'56','enable_recurring','Enable Recurring',1,0,0,100,1,$sorecurringinvoiceblock,1,'C~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID('vtiger_field').",'recurring_frequency','vtiger_invoice_recurring_info',1,'16','recurring_frequency','Frequency',1,0,0,100,2,$sorecurringinvoiceblock,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID('vtiger_field').",'start_period','vtiger_invoice_recurring_info',1,'5','start_period','Start Period',1,0,0,100,3,$sorecurringinvoiceblock,1,'D~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID('vtiger_field').",'end_period','vtiger_invoice_recurring_info',1,'5','end_period','End Period',1,0,0,100,4,$sorecurringinvoiceblock,1,'D~O~OTH~G~start_period~Start Period',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID('vtiger_field').",'payment_duration','vtiger_invoice_recurring_info',1,'16','payment_duration','Payment Duration',1,0,0,100,5,$sorecurringinvoiceblock,1,'V~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID('vtiger_field').",'invoice_status','vtiger_invoice_recurring_info',1,'15','invoicestatus','Invoice Status',1,0,0,100,6,$sorecurringinvoiceblock,1,'V~M',3,null,'BAS',0)"); + + //Sales Order Details -- END + + //Invoice Details -- START + //Block69 + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'subject','vtiger_invoice',1,'2','subject','Subject',1,0,0,100,1,$invoicebasicblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'salesorderid','vtiger_invoice',1,'80','salesorder_id','Sales Order',1,2,0,100,2,$invoicebasicblock,1,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'customerno','vtiger_invoice',1,'1','customerno','Customer No',1,2,0,100,3,$invoicebasicblock,1,'V~O',3,null,'BAS',1)"); + + + //to include contact name vtiger_field in Invoice-start + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'contactid','vtiger_invoice',1,'57','contact_id','Contact Name',1,2,0,100,4,$invoicebasicblock,1,'I~O',3,null,'BAS',1)"); + //end + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'invoicedate','vtiger_invoice',1,'5','invoicedate','Invoice Date',1,2,0,100,5,$invoicebasicblock,1,'D~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'duedate','vtiger_invoice',1,'5','duedate','Due Date',1,2,0,100,6,$invoicebasicblock,1,'D~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'purchaseorder','vtiger_invoice',1,'1','vtiger_purchaseorder','Purchase Order',1,2,0,100,8,$invoicebasicblock,1,'V~O',3,null,'BAS',1)"); + //$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_invoice',1,'1','txtTax','Sales Tax',1,0,0,100,9,69,3,'N~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'adjustment','vtiger_invoice',1,'1','txtAdjustment','Adjustment',1,2,0,100,9,$invoicebasicblock,3,'NN~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'salescommission','vtiger_invoice',1,'1','salescommission','Sales Commission',1,2,0,10,13,$invoicebasicblock,1,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'exciseduty','vtiger_invoice',1,'1','exciseduty','Excise Duty',1,2,0,100,11,$invoicebasicblock,1,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'subtotal','vtiger_invoice',1,'1','hdnSubTotal','Sub Total',1,2,0,100,12,$invoicebasicblock,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'total','vtiger_invoice',1,'1','hdnGrandTotal','Total',1,2,0,100,13,$invoicebasicblock,3,'N~O',3,null,'BAS',1)"); + //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'taxtype','vtiger_invoice',1,'16','hdnTaxType','Tax Type',1,2,0,100,13,$invoicebasicblock,3,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'discount_percent','vtiger_invoice',1,'1','hdnDiscountPercent','Discount Percent',1,2,0,100,13,$invoicebasicblock,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'discount_amount','vtiger_invoice',1,'1','hdnDiscountAmount','Discount Amount',1,2,0,100,13,$invoicebasicblock,3,'N~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'s_h_amount','vtiger_invoice',1,'1','hdnS_H_Amount','S&H Amount',1,2,0,100,14,57,3,'N~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'accountid','vtiger_invoice',1,'73','account_id','Account Name',1,2,0,100,14,$invoicebasicblock,1,'I~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'invoicestatus','vtiger_invoice',1,'15','invoicestatus','Status',1,2,0,100,15,$invoicebasicblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,16,$invoicebasicblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,17,$invoicebasicblock,2,'T~O',3,null,'BAS',0)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,18,$invoicebasicblock,2,'T~O',3,null,'BAS',0)"); + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'currency_id','vtiger_invoice',1,'117','currency_id','Currency',1,2,1,100,19,$invoicebasicblock,3,'I~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'conversion_rate','vtiger_invoice',1,'1','conversion_rate','Conversion Rate',1,2,1,100,20,$invoicebasicblock,3,'N~O',3,null,'BAS',1)"); + + //Block 71 + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_invoicebillads',1,'24','bill_street','Billing Address',1,2,0,100,1,$invoiceaddressblock,1,'V~M',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_invoiceshipads',1,'24','ship_street','Shipping Address',1,2,0,100,2,$invoiceaddressblock,1,'V~M',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_invoicebillads',1,'1','bill_city','Billing City',1,2,0,100,5,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_invoiceshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_invoicebillads',1,'1','bill_state','Billing State',1,2,0,100,7,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_invoiceshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_invoicebillads',1,'1','bill_code','Billing Code',1,2,0,100,9,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_invoiceshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_invoicebillads',1,'1','bill_country','Billing Country',1,2,0,100,11,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_invoiceshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_invoicebillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_invoiceshipads',1,'1','ship_pobox','Shipping Po Box',1,2,0,100,4,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)"); + + //Block73 + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,$invoicedescription,1,'V~O',3,null,'ADV',1)"); + //Block74 + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'terms_conditions','vtiger_invoice',1,'19','terms_conditions','Terms & Conditions',1,2,0,100,1,$invoicetermsblock,1,'V~O',3,null,'ADV',1)"); + //Added for Custom invoice Number + $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'invoice_no','vtiger_invoice',1,'4','invoice_no','Invoice No',1,0,0,100,3,$invoicebasicblock,1,'V~O',3,null,'BAS',0)"); + + //Invoice Details -- END + //users Details Starts Block 79,80,81 + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'user_name','vtiger_users',1,'106','user_name','User Name',1,0,0,11,1,$userloginandroleblockid,1,'V~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'is_admin','vtiger_users',1,'156','is_admin','Admin',1,0,0,3,2,$userloginandroleblockid,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'user_password','vtiger_users',1,'99','user_password','Password',1,0,0,30,3,$userloginandroleblockid,4,'P~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'confirm_password','vtiger_users',1,'99','confirm_password','Confirm Password',1,0,0,30,5,$userloginandroleblockid,4,'P~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'first_name','vtiger_users',1,'1','first_name','First Name',1,0,0,30,7,$userloginandroleblockid,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'last_name','vtiger_users',1,'2','last_name','Last Name',1,0,0,30,9,$userloginandroleblockid,1,'V~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'roleid','vtiger_user2role',1,'98','roleid','Role',1,0,0,200,11,$userloginandroleblockid,1,'V~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'email1','vtiger_users',1,'104','email1','Email',1,0,0,100,4,$userloginandroleblockid,1,'E~M',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'status','vtiger_users',1,'115','status','Status',1,0,0,100,6,$userloginandroleblockid,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'activity_view','vtiger_users',1,'16','activity_view','Default Activity View',1,0,0,100,12,$userloginandroleblockid,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'lead_view','vtiger_users',1,'16','lead_view','Default Lead View',1,0,0,100,10,$userloginandroleblockid,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'currency_id','vtiger_users',1,'117','currency_id','Currency',1,0,0,100,8,$userloginandroleblockid,1,'I~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'hour_format','vtiger_users',1,'116','hour_format','Calendar Hour Format',1,0,0,100,13,$userloginandroleblockid,3,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'end_hour','vtiger_users',1,'116','end_hour','Day ends at',1,0,0,100,15,$userloginandroleblockid,3,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'start_hour','vtiger_users',1,'116','start_hour','Day starts at',1,0,0,100,14,$userloginandroleblockid,3,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'title','vtiger_users',1,'1','title','Title',1,0,0,50,1,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'phone_work','vtiger_users',1,'1','phone_work','Office Phone',1,0,0,50,5,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'department','vtiger_users',1,'1','department','Department',1,0,0,50,3,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'phone_mobile','vtiger_users',1,'1','phone_mobile','Mobile',1,0,0,50,7,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'reports_to_id','vtiger_users',1,'101','reports_to_id','Reports To',1,0,0,50,8,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'phone_other','vtiger_users',1,'1','phone_other','Other Phone',1,0,0,50,11,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'email2','vtiger_users',1,'13','email2','Other Email',1,0,0,100,4,$usermoreinfoblock,1,'E~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'phone_fax','vtiger_users',1,'1','phone_fax','Fax',1,0,0,50,2,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'yahoo_id','vtiger_users',1,'13','yahoo_id','Yahoo id',1,0,0,100,6,$usermoreinfoblock,1,'E~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'phone_home','vtiger_users',1,'1','phone_home','Home Phone',1,0,0,50,9,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'date_format','vtiger_users',1,'16','date_format','Date Format',1,0,0,30,12,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'signature','vtiger_users',1,'21','signature','Signature',1,0,0,250,13,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_users',1,'21','description','Documents',1,0,0,250,14,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_street','vtiger_users',1,'21','address_street','Street Address',1,0,0,250,1,$useraddressblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_city','vtiger_users',1,'1','address_city','City',1,0,0,100,3,$useraddressblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_state','vtiger_users',1,'1','address_state','State',1,0,0,100,5,$useraddressblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_postalcode','vtiger_users',1,'1','address_postalcode','Postal Code',1,0,0,100,4,$useraddressblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_country','vtiger_users',1,'1','address_country','Country',1,0,0,100,2,$useraddressblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values(29,".$this->db->getUniqueID("vtiger_field").",'accesskey','vtiger_users',1,3,'accesskey','Webservice Access Key',1,0,0,100,2,$useradvanceblock,2,'V~O',1,null,'BAS',1);"); + + //User Image Information + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'imagename','vtiger_users',1,'105','imagename','User Image',1,0,0,250,10,$userblockid,1,'V~O',1,null,'BAS',1)"); + //added for internl_mailer + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'internal_mailer','vtiger_users',1,'56','internal_mailer','INTERNAL_MAIL_COMPOSER',1,0,0,50,15,$usermoreinfoblock,1,'V~O',1,null,'BAS',1)"); + $this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'reminder_interval','vtiger_users',1,'16','reminder_interval','Reminder Interval',1,0,0,100,1,$useradvanceblock,1,'V~O',1,null,'BAS',1)"); + //user Details End + + // Updated Phone field uitype + $this->db->query("update vtiger_field set uitype='11' where fieldname='mobile' and tabid=".getTabid('Leads')); + $this->db->query("update vtiger_field set uitype='11' where fieldname='mobile' and tabid=".getTabid('Contacts')); + $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=".getTabid('Leads')); + $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=".getTabid('Contacts')); + $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=".getTabid('Accounts')); + + $tab_field_array = array( + 'Accounts'=>array('accountname'), + 'Contacts'=>array('imagename'), + 'Products'=>array('imagename','product_id'), + 'Invoice'=>array('invoice_no','salesorder_id'), + 'SalesOrder'=>array('quote_id','salesorder_no'), + 'PurchaseOrder'=>array('purchaseorder_no'), + 'Quotes'=>array('quote_no'), + 'HelpDesk'=>array('filename'), + ); + foreach($tab_field_array as $index=>$value){ + $tabid = getTabid($index); + $this->db->pquery("UPDATE vtiger_field SET masseditable=0 WHERE tabid=? AND fieldname IN (".generateQuestionMarks($value).")",array($tabid,$value)); + } + + //Emails field added here + $email_Tabid = getTabid('Emails'); + $blockquery = "select blockid from vtiger_blocks where blocklabel = ?"; + $blockres = $this->db->pquery($blockquery,array('LBL_EMAIL_INFORMATION')); + $blockid = $this->db->query_result($blockres,0,'blockid'); + $this->db->query("INSERT INTO vtiger_field values($email_Tabid,".$this->db->getUniqueID("vtiger_field").",'from_email','vtiger_emaildetails',1,12,'from_email','From',1,2,0,100,1,$blockid,3,'V~M',3,NULL,'BAS',0)"); + $this->db->query("INSERT INTO vtiger_field values($email_Tabid,".$this->db->getUniqueID("vtiger_field").",'to_email','vtiger_emaildetails',1,8,'saved_toid','To',1,2,0,100,2,$blockid,1,'V~M',3,NULL,'BAS',0)"); + $this->db->query("INSERT INTO vtiger_field values($email_Tabid,".$this->db->getUniqueID("vtiger_field").",'cc_email','vtiger_emaildetails',1,8,'ccmail','CC',1,2,0,1000,3,$blockid,1,'V~O',3,NULL,'BAS',0)"); + $this->db->query("INSERT INTO vtiger_field values($email_Tabid,".$this->db->getUniqueID("vtiger_field").",'bcc_email','vtiger_emaildetails',1,8,'bccmail','BCC' ,1,2,0,1000,4,$blockid,1,'V~O',3,NULL,'BAS',0)"); + $this->db->query("INSERT INTO vtiger_field values($email_Tabid,".$this->db->getUniqueID("vtiger_field").",'idlists','vtiger_emaildetails',1,357,'parent_id','Parent ID' ,1,2,0,1000,5,$blockid,1,'V~O',3,NULL,'BAS',0)"); + $this->db->query("INSERT INTO vtiger_field values($email_Tabid,".$this->db->getUniqueID("vtiger_field").",'email_flag','vtiger_emaildetails',1,16,'email_flag','Email Flag' ,1,2,0,1000,6,$blockid,3,'V~O',3,NULL,'BAS',0)"); + //Emails fields ends + + //The Entity Name for the modules are maintained in this table + $this->db->query("insert into vtiger_entityname values(7,'Leads','vtiger_leaddetails','lastname,firstname','leadid','leadid')"); + $this->db->query("insert into vtiger_entityname values(6,'Accounts','vtiger_account','accountname','accountid','account_id')"); + $this->db->query("insert into vtiger_entityname values(4,'Contacts','vtiger_contactdetails','lastname,firstname','contactid','contact_id')"); + $this->db->query("insert into vtiger_entityname values(2,'Potentials','vtiger_potential','potentialname','potentialid','potential_id')"); + $this->db->query("insert into vtiger_entityname values(8,'Documents','vtiger_notes','title','notesid','notesid')"); + $this->db->query("insert into vtiger_entityname values(13,'HelpDesk','vtiger_troubletickets','title','ticketid','ticketid')"); + $this->db->query("insert into vtiger_entityname values(9,'Calendar','vtiger_activity','subject','activityid','activityid')"); + $this->db->query("insert into vtiger_entityname values(10,'Emails','vtiger_activity','subject','activityid','activityid')"); + $this->db->query("insert into vtiger_entityname values(14,'Products','vtiger_products','productname','productid','product_id')"); + $this->db->query("insert into vtiger_entityname values(29,'Users','vtiger_users','last_name,first_name','id','id')"); + $this->db->query("insert into vtiger_entityname values(23,'Invoice','vtiger_invoice','subject','invoiceid','invoiceid')"); + $this->db->query("insert into vtiger_entityname values(20,'Quotes','vtiger_quotes','subject','quoteid','quote_id')"); + $this->db->query("insert into vtiger_entityname values(21,'PurchaseOrder','vtiger_purchaseorder','subject','purchaseorderid','purchaseorderid')"); + $this->db->query("insert into vtiger_entityname values(22,'SalesOrder','vtiger_salesorder','subject','salesorderid','salesorder_id')"); + $this->db->query("insert into vtiger_entityname values(18,'Vendors','vtiger_vendor','vendorname','vendorid','vendor_id')"); + $this->db->query("insert into vtiger_entityname values(19,'PriceBooks','vtiger_pricebook','bookname','pricebookid','pricebookid')"); + $this->db->query("insert into vtiger_entityname values(26,'Campaigns','vtiger_campaign','campaignname','campaignid','campaignid')"); + $this->db->query("insert into vtiger_entityname values(15,'Faq','vtiger_faq','question','id','id')"); + // Insert End + + + //Inserting values into org share action mapping + $this->db->query("insert into vtiger_org_share_action_mapping values(0,'Public: Read Only')"); + $this->db->query("insert into vtiger_org_share_action_mapping values(1,'Public: Read, Create/Edit')"); + $this->db->query("insert into vtiger_org_share_action_mapping values(2,'Public: Read, Create/Edit, Delete')"); + $this->db->query("insert into vtiger_org_share_action_mapping values(3,'Private')"); + + $this->db->query("insert into vtiger_org_share_action_mapping values(4,'Hide Details')"); + $this->db->query("insert into vtiger_org_share_action_mapping values(5,'Hide Details and Add Events')"); + $this->db->query("insert into vtiger_org_share_action_mapping values(6,'Show Details')"); + $this->db->query("insert into vtiger_org_share_action_mapping values(7,'Show Details and Add Events')"); + + + //Inserting for all vtiger_tabs + $def_org_tabid= Array(2,4,6,7,8,9,10,13,16,20,21,22,23,26); + + foreach($def_org_tabid as $def_tabid) + { + $this->db->query("insert into vtiger_org_share_action2tab values(0,".$def_tabid.")"); + $this->db->query("insert into vtiger_org_share_action2tab values(1,".$def_tabid.")"); + $this->db->query("insert into vtiger_org_share_action2tab values(2,".$def_tabid.")"); + $this->db->query("insert into vtiger_org_share_action2tab values(3,".$def_tabid.")"); + } + + //Insert into default_org_sharingrule + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",2,2,0)"); + + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",4,2,2)"); + + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",6,2,0)"); + + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",7,2,0)"); + + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",9,3,1)"); + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",13,2,0)"); + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",16,3,2)"); + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",20,2,0)"); + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",21,2,0)"); + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",22,2,0)"); + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",23,2,0)"); + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",26,2,0)"); + $this->db->query("insert into vtiger_def_org_share values (".$this->db->getUniqueID('vtiger_def_org_share').",8,2,0)"); + + //Populating the DataShare Related Modules + + //Lead Related Module + + //Account Related Module + $this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('vtiger_datashare_relatedmodules').",6,2)"); + $this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('vtiger_datashare_relatedmodules').",6,13)"); + $this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('vtiger_datashare_relatedmodules').",6,20)"); + $this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('vtiger_datashare_relatedmodules').",6,22)"); + $this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('vtiger_datashare_relatedmodules').",6,23)"); + + //Potential Related Module + $this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('vtiger_datashare_relatedmodules').",2,20)"); + $this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('vtiger_datashare_relatedmodules').",2,22)"); + + //Quote Related Module + $this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('vtiger_datashare_relatedmodules').",20,22)"); + + //SO Related Module + $this->db->query("insert into vtiger_datashare_relatedmodules values (".$this->db->getUniqueID('vtiger_datashare_relatedmodules').",22,23)"); + + + + + // New Secutity End + + + //insert into the vtiger_notificationscheduler vtiger_table + + //insert into related list vtiger_table + //Inserting for vtiger_account related lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Potentials").",'get_opportunities',2,'Potentials',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Quotes").",'get_quotes',3,'Quotes',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("SalesOrder").",'get_salesorder',4,'Sales Order',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Invoice").",'get_invoices',5,'Invoice',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Calendar").",'get_activities',6,'Activities',0,'add')"); + + //added for the ticket4109 + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Emails").",'get_emails',7,'Emails',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Calendar").",'get_history',8,'Activity History',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Documents").",'get_attachments',9,'Documents',0,'add,select')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("HelpDesk").",'get_tickets',10,'HelpDesk',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Products").",'get_products',11,'Products',0,'select')"); + + //Inserting Lead Related Lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Leads").",".getTabid("Calendar").",'get_activities',1,'Activities',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Leads").",".getTabid("Emails").",'get_emails',2,'Emails',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Leads").",".getTabid("Calendar").",'get_history',3,'Activity History',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Leads").",".getTabid("Documents").",'get_attachments',4,'Documents',0,'add,select')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Leads").",".getTabid("Products").",'get_products',5,'Products',0,'select')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Leads").",".getTabid("Campaigns").",'get_campaigns',6,'Campaigns',0,'select')"); + + //Inserting for contact related lists + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("Potentials").",'get_opportunities',1,'Potentials',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("Calendar").",'get_activities',2,'Activities',0,'add')"); + + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("Emails").",'get_emails',3,'Emails',0,'add')"); + + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("HelpDesk").",'get_tickets',4,'HelpDesk',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("Quotes").",'get_quotes',5,'Quotes',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("PurchaseOrder").",'get_purchase_orders',6,'Purchase Order',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("SalesOrder").",'get_salesorder',7,'Sales Order',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("Products").",'get_products',8,'Products',0,'select')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("Calendar").",'get_history',9,'Activity History',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("Documents").",'get_attachments',10,'Documents',0,'add,select')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Contacts").",".getTabid("Campaigns").",'get_campaigns',11,'Campaigns',0,'select')"); + + $this->db->query("INSERT INTO vtiger_relatedlists VALUES(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid('Contacts').",".getTabid('Invoice').",'get_invoices',12,'Invoice',0, 'add')"); + + //Inserting Potential Related Lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Potentials").",".getTabid("Calendar").",'get_activities',1,'Activities',0,'add')"); + + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Potentials").",".getTabid("Contacts").",'get_contacts',2,'Contacts',0,'select')"); + + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Potentials").",".getTabid("Products").",'get_products',3,'Products',0,'select')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Potentials").",0,'get_stage_history',4,'Sales Stage History',0,'')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Potentials").",".getTabid("Documents").",'get_attachments',5,'Documents',0,'add,select')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Potentials").",".getTabid("Quotes").",'get_Quotes',6,'Quotes',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Potentials").",".getTabid("SalesOrder").",'get_salesorder',7,'Sales Order',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Potentials").",".getTabid("Calendar").",'get_history',8,'Activity History',0,'')"); + + //Inserting Product Related Lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("HelpDesk").",'get_tickets',1,'HelpDesk',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Documents").",'get_attachments',3,'Documents',0,'add,select')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Quotes").",'get_quotes',4,'Quotes',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("PurchaseOrder").",'get_purchase_orders',5,'Purchase Order',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("SalesOrder").",'get_salesorder',6,'Sales Order',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Invoice").",'get_invoices',7,'Invoice',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("PriceBooks").",'get_product_pricebooks',8,'PriceBooks',0,'add')"); + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Leads").",'get_leads',9,'Leads',0,'select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Accounts").",'get_accounts',10,'Accounts',0,'select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Contacts").",'get_contacts',11,'Contacts',0,'select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Potentials").",'get_opportunities',12,'Potentials',0,'select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Products").",'get_products',13,'Product Bundles',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Products").",'get_parent_products',14,'Parent Product',0,'')"); + + //Inserting Emails Related Lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Emails").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0,'select,bulkmail')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Emails").",0,'get_users',2,'Users',0,'')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Emails").",".getTabid("Documents").",'get_attachments',3,'Documents',0,'add,select')"); + + //Inserting HelpDesk Related Lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("HelpDesk").",".getTabid("Calendar").",'get_activities',1,'Activities',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("HelpDesk").",".getTabid("Documents").",'get_attachments',2,'Documents',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("HelpDesk").",0,'get_ticket_history',3,'Ticket History',0,'')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("HelpDesk").",".getTabid("Calendar").",'get_history',4,'Activity History',0,'')"); + + //Inserting PriceBook Related Lists + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("PriceBooks").",14,'get_pricebook_products',2,'Products',0,'select')"); + + // Inserting Vendor Related Lists + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Vendors").",14,'get_products',1,'Products',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Vendors").",21,'get_purchase_orders',2,'Purchase Order',0,'add')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Vendors").",4,'get_contacts',3,'Contacts',0,'select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Vendors").",".getTabid("Emails").",'get_emails',4,'Emails',0,'add')"); + + // Inserting Quotes Related Lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Quotes").",".getTabid("SalesOrder").",'get_salesorder',1,'Sales Order',0,'')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Quotes").",9,'get_activities',2,'Activities',0,'add')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Quotes").",".getTabid("Documents").",'get_attachments',3,'Documents',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Quotes").",9,'get_history',4,'Activity History',0,'')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Quotes").",0,'get_quotestagehistory',5,'Quote Stage History',0,'')"); + + // Inserting Purchase order Related Lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("PurchaseOrder").",9,'get_activities',1,'Activities',0,'add')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("PurchaseOrder").",".getTabid("Documents").",'get_attachments',2,'Documents',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("PurchaseOrder").",".getTabid("Calendar").",'get_history',3,'Activity History',0,'')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("PurchaseOrder").",0,'get_postatushistory',4,'PurchaseOrder Status History',0,'')"); + + // Inserting Sales order Related Lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("SalesOrder").",9,'get_activities',1,'Activities',0,'add')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("SalesOrder").",".getTabid("Documents").",'get_attachments',2,'Documents',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("SalesOrder").",".getTabid("Invoice").",'get_invoices',3,'Invoice',0,'')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("SalesOrder").",".getTabid("Calendar").",'get_history',4,'Activity History',0,'')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("SalesOrder").",0,'get_sostatushistory',5,'SalesOrder Status History',0,'')"); + + // Inserting Invoice Related Lists + + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Invoice").",9,'get_activities',1,'Activities',0,'add')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Invoice").",".getTabid("Documents").",'get_attachments',2,'Documents',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Invoice").",".getTabid("Calendar").",'get_history',3,'Activity History',0,'')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Invoice").",0,'get_invoicestatushistory',4,'Invoice Status History',0,'')"); + + // Inserting Activities Related Lists + + $this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Calendar").",0,'get_users',1,'Users',0,'')"); + $this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Calendar").",4,'get_contacts',2,'Contacts',0,'')"); + + // Inserting Campaigns Related Lists + + $this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Campaigns").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Campaigns").",".getTabid("Leads").",'get_leads',2,'Leads',0,'add,select')"); + $this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Campaigns").",".getTabid("Potentials").",'get_opportunities',3,'Potentials',0,'add')"); + $this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Campaigns").",9,'get_activities',4,'Activities',0,'add')"); + $this->db->query("INSERT INTO vtiger_relatedlists VALUES (".$this->db->getUniqueID('vtiger_relatedlists').", ".getTabid("Accounts").", ".getTabid("Campaigns").", 'get_campaigns', 13, 'Campaigns', 0, 'select')"); + $this->db->query("INSERT INTO vtiger_relatedlists VALUES (".$this->db->getUniqueID('vtiger_relatedlists').", ".getTabid("Campaigns").", ".getTabid("Accounts").", 'get_accounts', 5, 'Accounts', 0, 'add,select')"); + + // Inserting Faq's Related Lists + $this->db->query("insert into vtiger_relatedlists values (".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Faq").",".getTabid("Documents").",'get_attachments',1,'Documents',0,'add,select')"); + + $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_notificationscheduler").",'LBL_TASK_NOTIFICATION_DESCRITPION',1,'Task Delay Notification','Tasks delayed beyond 24 hrs ','LBL_TASK_NOTIFICATION')"); + $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_notificationscheduler").",'LBL_BIG_DEAL_DESCRIPTION' ,1,'Big Deal notification','Success! A big deal has been won! ','LBL_BIG_DEAL')"); + $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_notificationscheduler").",'LBL_TICKETS_DESCRIPTION',1,'Pending Tickets notification','Ticket pending please ','LBL_PENDING_TICKETS')"); + $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_notificationscheduler").",'LBL_MANY_TICKETS_DESCRIPTION',1,'Too many tickets Notification','Too many tickets pending against this entity ','LBL_MANY_TICKETS')"); + $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (".$this->db->getUniqueID("vtiger_notificationscheduler").",'LBL_START_DESCRIPTION' ,1,'Support Start Notification','10','LBL_START_NOTIFICATION','select')"); + $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (".$this->db->getUniqueID("vtiger_notificationscheduler").",'LBL_SUPPORT_DESCRIPTION',1,'Support ending please','11','LBL_SUPPORT_NOTICIATION','select')"); + $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (".$this->db->getUniqueID("vtiger_notificationscheduler").",'LBL_SUPPORT_DESCRIPTION_MONTH',1,'Support ending please','12','LBL_SUPPORT_NOTICIATION_MONTH','select')"); + $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_notificationscheduler").",'LBL_ACTIVITY_REMINDER_DESCRIPTION' ,1,'Activity Reminder Notification','This is a reminder notification for the Activity','LBL_ACTIVITY_NOTIFICATION')"); + + //inserting actions for get_attachments + $folderid = $this->db->getUniqueID("vtiger_attachmentsfolder"); + $this->db->query("insert into vtiger_attachmentsfolder values(".$folderid.",'Default','This is a Default Folder',1,1)"); + + //Inserting Inventory Notifications + $invoice_body = 'Dear {HANDLER}, + +The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. Kindly procure required number of units as the stock level is below reorder level {REORDERLEVELVALUE}. + +Please treat this information as Urgent as the invoice is already sent to the customer. + +Severity: Critical + +Thanks, +{CURRENTUSER}'; + + + $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_inventorynotification").",'InvoiceNotification','{PRODUCTNAME} Stock Level is Low','".$invoice_body." ','InvoiceNotificationDescription')"); + + $quote_body = 'Dear {HANDLER}, + +Quote is generated for {QUOTEQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. + +Severity: Minor + +Thanks, +{CURRENTUSER}'; + + + $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_inventorynotification").",'QuoteNotification','Quote given for {PRODUCTNAME}','".$quote_body." ','QuoteNotificationDescription')"); + + $so_body = 'Dear {HANDLER}, + +SalesOrder is generated for {SOQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. + +Please treat this information with priority as the sales order is already generated. + +Severity: Major + +Thanks, +{CURRENTUSER}'; + + + $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_inventorynotification").",'SalesOrderNotification','Sales Order generated for {PRODUCTNAME}','".$so_body." ','SalesOrderNotificationDescription')"); + +//insert into inventory terms and conditions table + + $inv_tandc_text=' + - Unless otherwise agreed in writing by the supplier all invoices are payable within thirty (30) days of the date of invoice, in the currency of the invoice, drawn on a bank based in India or by such other method as is agreed in advance by the Supplier. + + - All prices are not inclusive of VAT which shall be payable in addition by the Customer at the applicable rate.'; + + $this->db->query("insert into vtiger_inventory_tandc(id,type,tandc) values (".$this->db->getUniqueID("vtiger_inventory_tandc").", 'Inventory', '".$inv_tandc_text."')"); + +//insert into email template vtiger_table + + $body='Hello!
| + | + | + | ||||||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||||||
| + |
+
|
+ + | ||||||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||||||
| + | + | + |
| + | + | + | ||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||
| + |
+
|
+ + | ||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||
| + | + | + |
| + | + | + | ||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||
| + |
+
|
+ + | ||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||
| + | + | + | ||||||||||||||||||||||
| + | + | + |
| + User does not exist. + | +
| + List Users + | +
|
+
+
+
|
![]() |
+
![]() |
+ ![]() |
+
+
+
+ |
+
+
+
+ + + |
+