Ejemplo n.º 1
0
 function clone01($lTableID, $lFieldID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     if (!bTestForURLHack('adminOnly')) {
         return;
     }
     $displayData = array();
     $displayData['js'] = '';
     $displayData['lTableID'] = $lTableID = (int) $lTableID;
     $displayData['lFieldID'] = $lFieldID = (int) $lFieldID;
     //---------------------------------
     // models and helpers
     //---------------------------------
     $params = array('enumStyle' => 'enpRpt');
     $this->load->library('generic_rpt', $params);
     $this->load->model('personalization/muser_fields', 'clsUF');
     $this->load->model('personalization/muser_ddl_clone', 'cClone');
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->helper('clients/client_program');
     $this->load->helper('personalization/link_personalization');
     $this->load->helper('dl_util/web_layout');
     //-------------------------------------
     // stripes
     //-------------------------------------
     $this->load->model('util/mbuild_on_ready', 'clsOnReady');
     $this->clsOnReady->addOnReadyTableStripes();
     $this->clsOnReady->closeOnReady();
     $displayData['js'] .= $this->clsOnReady->strOnReady;
     $this->clsUF->lTableID = $lTableID;
     $this->clsUF->loadTableViaTableID();
     $enumTType = $this->clsUF->userTables[0]->enumTType;
     $this->clsUF->uf_ddl_info($lFieldID);
     $this->clsUF->loadSingleField($lFieldID);
     $displayData['targetDDLInfo'] =& $this->clsUF->clsDDL_Info;
     // http://stackoverflow.com/questions/21498038/php-pointer-returns-null
     setClientProgFields($displayData, $bClientProg, $lCProgID, $cprog, $enumTType, $lTableID);
     $this->cClone->loadAllDDLMultDDL($displayData['lNumDDLs'], $displayData['ddls']);
     //-----------------------------
     // breadcrumbs and headers
     //-----------------------------
     if ($bClientProg) {
         $displayData['title'] = CS_PROGNAME . ' | Client Programs';
         $displayData['pageTitle'] = anchor('main/menu/admin', 'Admin', 'class="breadcrumb"') . ' | ' . anchor('cprograms/cprograms/overview', 'Client Programs', 'class="breadcrumb"') . ' | ' . anchor('cprograms/cprog_record/view/' . $lCProgID, htmlspecialchars($cprog->strProgramName), 'class="breadcrumb"') . ' | ' . anchor('admin/uf_fields/view/' . $lTableID, 'Fields', 'class="breadcrumb"') . ' | Clone Drop-down List';
     } else {
         $displayData['title'] = CS_PROGNAME . ' | Personalization';
         $displayData['pageTitle'] = anchor('main/menu/admin', 'Admin', 'class="breadcrumb"') . ' | ' . anchor('admin/personalization/overview', 'Personalization', 'class="breadcrumb"') . ' | ' . anchor('admin/uf_fields/view/' . $lTableID, 'Fields', 'class="breadcrumb"') . ' | Clone Drop-down List';
     }
     $displayData['mainTemplate'] = 'personalization/ddl_clone_selection_view';
     $displayData['nav'] = $this->mnav_brain_jar->navData();
     $this->load->vars($displayData);
     $this->load->view('template');
 }
Ejemplo n.º 2
0
 function addEditDDLEntry($lTableID, $lFieldID, $lDDLEntryID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     if (!bTestForURLHack('adminOnly')) {
         return;
     }
     $displayData = array();
     $displayData['lTableID'] = $lTableID = (int) $lTableID;
     $displayData['lFieldID'] = $lFieldID = (int) $lFieldID;
     $displayData['lDDLEntryID'] = $lDDLEntryID = (int) $lDDLEntryID;
     $bNew = $lDDLEntryID <= 0;
     //---------------------------------
     // models and helpers
     //---------------------------------
     $this->load->helper('clients/client_program');
     $this->load->model('personalization/muser_fields', 'clsUF');
     $this->load->model('admin/mpermissions', 'perms');
     $params = array('enumStyle' => 'enpRpt');
     $this->load->library('generic_rpt', $params);
     $displayData['lTableID'] = $this->clsUF->lTableID = $lTableID;
     $this->clsUF->loadTableViaTableID();
     $enumTType = $this->clsUF->userTables[0]->enumTType;
     $this->clsUF->uf_ddl_info($lFieldID);
     $this->clsUF->loadSingleField($lFieldID);
     // validation rules
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>');
     $this->form_validation->set_rules('txtDDLEntry', 'Drop-down List Entry', 'trim|callback_ufDDLAddEditUnique[' . $lFieldID . ',' . $lDDLEntryID . ']');
     setClientProgFields($displayData, $bClientProg, $lCProgID, $cprog, $enumTType, $lTableID);
     if ($this->form_validation->run() == FALSE) {
         $this->load->library('generic_form');
         $displayData['strUserTableName'] = $this->clsUF->userTables[0]->strUserTableName;
         $displayData['strUserFieldName'] = $this->clsUF->fields[0]->pff_strFieldNameUser;
         if (validation_errors() == '') {
             $displayData['strDDLEntry'] = $this->clsUF->strDDLValue($lDDLEntryID);
         } else {
             setOnFormError($displayData);
             $displayData['strDDLEntry'] = set_value('txtDDLEntry');
         }
         //--------------------------
         // breadcrumbs
         //--------------------------
         if ($bClientProg) {
             $displayData['title'] = CS_PROGNAME . ' | Client Programs';
             $displayData['pageTitle'] = anchor('main/menu/admin', 'Admin', 'class="breadcrumb"') . ' | ' . anchor('cprograms/cprograms/overview', 'Client Programs', 'class="breadcrumb"') . ' | ' . anchor('cprograms/cprog_record/view/' . $lCProgID, htmlspecialchars($cprog->strProgramName), 'class="breadcrumb"') . ' | ' . anchor('admin/uf_fields/view/' . $lTableID, 'Fields', 'class="breadcrumb"') . ' | ' . anchor('admin/uf_ddl/configDDL/' . $lTableID . '/' . $lFieldID, 'Drop-down List Entries', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add new ' : 'Update ') . 'list entry';
         } else {
             $displayData['pageTitle'] = anchor('main/menu/admin', 'Admin', 'class="breadcrumb"') . ' | ' . anchor('admin/personalization/overview', 'Personalization', 'class="breadcrumb"') . ' | ' . anchor('admin/uf_fields/view/' . $lTableID, 'Fields', 'class="breadcrumb"') . ' | ' . anchor('admin/uf_ddl/configDDL/' . $lTableID . '/' . $lFieldID, 'Drop-down List Entries', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add new ' : 'Update ') . 'list entry';
             $displayData['title'] = CS_PROGNAME . ' | Personalization';
         }
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['bNew'] = $bNew;
         $displayData['mainTemplate'] = 'personalization/ddl_add_edit_entry_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $strDDLEntry = trim($_POST['txtDDLEntry']);
         if ($bNew) {
             $this->clsUF->setDDL_asConfigured($lFieldID);
             $lNewSortIDX = $this->clsUF->clsDDL_Info->lMaxSortIDX + 1;
             $lDDLEntryID = $this->clsUF->addUF_DDLEntry($strDDLEntry, $lFieldID, $lNewSortIDX);
             $this->session->set_flashdata('msg', 'The drop-down list entry was added');
         } else {
             $this->clsUF->updateUF_DDLEntry($strDDLEntry, $lDDLEntryID);
             $this->session->set_flashdata('msg', 'The drop-down list entry was updated');
         }
         redirect('admin/uf_ddl/configDDL/' . $lTableID . '/' . $lFieldID);
     }
 }
 function addField2a($lTableID, $lFieldID, $enumFieldType)
 {
     //----------------------------------------------------------------------
     //
     //----------------------------------------------------------------------
     global $gclsChapterACO;
     if (!bTestForURLHack('adminOnly')) {
         return;
     }
     $displayData = array();
     $displayData['opts'] = new stdClass();
     $displayData['lTableID'] = $lTableID = (int) $lTableID;
     $displayData['lFieldID'] = $lFieldID = (int) $lFieldID;
     $displayData['bNew'] = $bNew = $lFieldID <= 0;
     $displayData['enumFieldType'] = $enumFieldType;
     //-------------------------
     // models and helpers
     //-------------------------
     $this->load->model('personalization/muser_fields');
     $this->load->model('personalization/muser_fields_create', 'clsUFC');
     $this->load->model('admin/mpermissions', 'perms');
     $this->load->helper('clients/client_program');
     $params = array('enumStyle' => 'enpRptC');
     $this->load->library('generic_rpt', $params);
     $this->clsUFC->lTableID = $lTableID;
     $this->clsUFC->loadTableViaTableID();
     $uTable =& $this->clsUFC->userTables[0];
     $enumTType = $uTable->enumTType;
     $this->clsUF =& $this->clsUFC;
     // satisfy the reference in client_program_helper
     setClientProgFields($displayData, $bClientProg, $lCProgID, $cprog, $enumTType, $lTableID);
     $displayData['strUserTableName'] = $uTable->strUserTableName;
     $this->clsUFC->strENPTableName = $uTable->strDataTableName;
     $displayData['bMultiEntry'] = $bMultiEntry = $uTable->bMultiEntry;
     $displayData['bShowRequired'] = $bShowRequired = $bMultiEntry && !($enumFieldType == CS_FT_CHECKBOX || $enumFieldType == CS_FT_LOG || $enumFieldType == CS_FT_HEADING);
     //---------------------
     // field info
     //---------------------
     $this->clsUFC->loadFieldTypes();
     $this->clsUFC->loadSingleField($lFieldID, false);
     $displayData['strFieldTypeLabel'] = $this->clsUFC->strFieldTypeLabel($enumFieldType);
     $uField =& $this->clsUFC->fields[0];
     $this->setVerificationViaFieldType($enumFieldType, $lTableID, $lFieldID);
     if ($bShowRequired) {
         $this->form_validation->set_rules('chkRequired');
     }
     if ($this->form_validation->run() == FALSE) {
         $this->load->library('generic_form');
         //         $displayData['entrySummary'] = $this->clsUFC->strUFTableSummaryDisplay(true);
         if (validation_errors() == '') {
             $displayData['strFieldNameUser'] = htmlspecialchars($uField->pff_strFieldNameUser);
             $displayData['strFieldNotes'] = htmlspecialchars($uField->strFieldNotes);
             $displayData['opts']->lDDLDefault = $uField->pff_lDDLDefault;
             $displayData['opts']->bCheckDef = $uField->pff_bCheckDef;
             $displayData['opts']->curDef = $uField->pff_curDef;
             $displayData['opts']->lCurrencyACO = $uField->pff_lCurrencyACO;
             $displayData['opts']->bHidden = $uField->pff_bHidden;
             $displayData['opts']->bPrefill = $uField->bPrefilled;
             $displayData['opts']->strTxtDef = htmlspecialchars($uField->pff_strTxtDef);
             $displayData['opts']->lDef = $uField->pff_lDef;
             if ($bShowRequired) {
                 $displayData['opts']->bRequired = $uField->pff_bRequired;
             }
         } else {
             setOnFormError($displayData);
             $displayData['strFieldNameUser'] = set_value('txtFieldName');
             $displayData['strFieldNotes'] = set_value('txtFieldNotes');
             $displayData['opts']->lDDLDefault = 0;
             $displayData['opts']->bCheckDef = @$_POST['rdoDefaultYN'] == 'YES';
             $displayData['opts']->curDef = @$_POST['txtDefaultCur'];
             $displayData['opts']->lCurrencyACO = @$_POST['rdoACO'];
             $displayData['opts']->bHidden = @$_POST['chkHidden'] == 'true';
             $displayData['opts']->bPrefill = @$_POST['chkPrefill'] == 'true';
             $displayData['opts']->strTxtDef = @$_POST['txtDefaultText'];
             $displayData['opts']->lDef = @$_POST['txtDefaultInt'];
             if ($bShowRequired) {
                 $displayData['opts']->bRequired = set_value('chkRequired') == 'true';
             }
         }
         $displayData['lTableID'] = $lTableID = (int) $lTableID;
         //-----------------------------
         // breadcrumbs and headers
         //-----------------------------
         if ($bClientProg) {
             $displayData['title'] = CS_PROGNAME . ' | Client Programs';
             $displayData['pageTitle'] = anchor('main/menu/admin', 'Admin', 'class="breadcrumb"') . ' | ' . anchor('cprograms/cprograms/overview', 'Client Programs', 'class="breadcrumb"') . ' | ' . anchor('cprograms/cprog_record/view/' . $lCProgID, htmlspecialchars($cprog->strProgramName), 'class="breadcrumb"') . ' | ' . anchor('admin/uf_fields/view/' . $lTableID, 'Fields', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add new ' : 'Update ') . 'Field';
         } else {
             $displayData['title'] = CS_PROGNAME . ' | Personalization';
             $displayData['pageTitle'] = anchor('main/menu/admin', 'Admin', 'class="breadcrumb"') . ' | ' . anchor('admin/personalization/overview/' . $enumTType, 'Personalization', 'class="breadcrumb"') . ' | ' . anchor('admin/uf_fields/view/' . $lTableID, 'Fields', 'class="breadcrumb"') . ' | ' . ($bNew ? 'Add new ' : 'Update ') . 'Field';
         }
         $displayData['nav'] = $this->mnav_brain_jar->navData();
         $displayData['mainTemplate'] = 'personalization/uf_add_field_info_view';
         $this->load->vars($displayData);
         $this->load->view('template');
     } else {
         $this->load->helper('dl_util/util_db');
         $this->strENPTableName = $this->clsUFC->userTables[0]->strUserTableName;
         $uField->pff_strFieldNameUser = $strUserFieldName = trim($_POST['txtFieldName']);
         $uField->strFieldNotes = trim($_POST['txtFieldNotes']);
         $uField->pff_bCheckDef = false;
         $uField->pff_bDDLMasterList = false;
         $uField->pff_bHidden = @$_POST['chkHidden'] == 'true';
         $uField->bPrefilled = @$_POST['chkPrefill'] == 'true';
         $uField->pff_curDef = 0;
         $uField->pff_strTxtDef = '';
         $uField->pff_lDef = -1;
         $uField->pff_lCurrencyACO = $gclsChapterACO->lKeyID;
         if ($bShowRequired) {
             $uField->pff_bRequired = trim(@$_POST['chkRequired']) == 'true';
         }
         if ($bNew) {
             $uField->enumFieldType = $enumFieldType;
         } else {
             if (isset($_POST['rdoACO'])) {
                 $uField->pff_lCurrencyACO = (int) $_POST['rdoACO'];
             }
         }
         switch ($enumFieldType) {
             case CS_FT_CHECKBOX:
                 $this->setup_CheckBox($bNew, $this->clsUFC, @$_POST['rdoDefaultYN'] == 'YES');
                 break;
             case CS_FT_DATE:
             case CS_FT_DATETIME:
                 $this->setup_DateTime($bNew, $this->clsUFC);
                 break;
             case CS_FT_TEXT255:
             case CS_FT_TEXT80:
             case CS_FT_TEXT20:
                 $this->setup_Text($bNew, $this->clsUFC);
                 break;
             case CS_FT_TEXTLONG:
                 $this->setup_TextLong($bNew, $this->clsUFC);
                 break;
             case CS_FT_HEADING:
                 $this->setup_TextLong($bNew, $this->clsUFC);
                 break;
             case CS_FT_INTEGER:
                 $this->setup_Integer($bNew, $this->clsUFC, (int) trim($_POST['txtDefaultInt']));
                 break;
             case CS_FT_CLIENTID:
                 $this->setup_Integer($bNew, $this->clsUFC, 0);
                 break;
             case CS_FT_CURRENCY:
                 $this->setup_Currency($bNew, $this->clsUFC, trim($_POST['txtDefaultCur']), $_POST['rdoACO']);
                 break;
             case CS_FT_DDL:
             case CS_FT_DDLMULTI:
                 $this->setup_DDL_PartOne($bNew, $this->clsUFC);
                 break;
             case CS_FT_LOG:
                 $this->setup_Log($bNew, $this->clsUFC);
                 break;
             default:
                 screamForHelp('Invalid field type ' . $lFieldType . ' detected, error on line ' . __LINE__ . ', file ' . __FILE__ . ', function ' . __FUNCTION__);
                 break;
         }
         // embed the field ID in the message for Sahi testing
         $lFieldID = $this->clsUFC->fields[0]->pff_lKeyID;
         $strHiddenFID = '<div id="divFieldID" style="display: none;">' . $lFieldID . '</div>' . "\n";
         if ($bNew) {
             $this->session->set_flashdata('msg', 'New field <b>"' . htmlspecialchars($strUserFieldName) . '"</b> added' . $strHiddenFID);
         } else {
             $this->session->set_flashdata('msg', 'Field <b>"' . htmlspecialchars($strUserFieldName) . '"</b> updated' . $strHiddenFID);
         }
         redirect('admin/uf_fields/view/' . $lTableID);
     }
 }