}
     $ranklist .= "' /></font>\n";
     $ranklist .= "<img src='{$imageurl}/cut.gif' alt='" . $blang->gT("Remove this item") . "' title='" . $blang->gT("Remove this item") . "' ";
     if (!isset($existing) || $i != $existing) {
         $ranklist .= "style='display:none'";
     }
     $mfn = $fieldname . $i;
     $ranklist .= " id='cut_{$thisqid}{$i}' onclick=\"deletethis_{$thisqid}(document.addsurvey.RANK_{$thisqid}{$i}.value, document.addsurvey.d{$fieldname}{$i}.value, document.addsurvey.RANK_{$thisqid}{$i}.id, this.id)\" /><br />\n\n";
 }
 if (!isset($choicelist)) {
     $choicelist = "";
 }
 $choicelist .= "<select size='{$anscount}' class='choicelist' name='CHOICES' id='CHOICES_{$thisqid}' onclick=\"rankthis_{$thisqid}(this.options[this.selectedIndex].value, this.options[this.selectedIndex].text)\" >\n";
 foreach ($answers as $ans) {
     if (_PHPVERSION < "4.2.0") {
         if (!array_in_array($ans, $chosen)) {
             $choicelist .= "\t<option value='{$ans[0]}'>{$ans[1]}</option>\n";
         }
     } else {
         if (!in_array($ans, $chosen)) {
             $choicelist .= "\t<option value='{$ans[0]}'>{$ans[1]}</option>\n";
         }
     }
 }
 $choicelist .= "</select>\n";
 $dataentryoutput .= "\t<table align='left' border='0' cellspacing='5'>\n" . "<tr>\n" . "\t<td align='left' valign='top' width='200'>\n" . "<strong>" . $blang->gT("Your Choices") . ":</strong><br />\n" . $choicelist . "\t</td>\n" . "\t<td align='left'>\n" . "<strong>" . $blang->gT("Your Ranking") . ":</strong><br />\n" . $ranklist . "\t</td>\n" . "</tr>\n" . "\t</table>\n" . "\t<input type='hidden' name='multi' value='{$anscount}' />\n" . "\t<input type='hidden' name='lastfield' value='";
 if (isset($multifields)) {
     $dataentryoutput .= $multifields;
 }
 $dataentryoutput .= "' />\n";
 $choicelist = "";
 public function get_revision_unsigned_admin($revision_SN)
 {
     $report_revision = $this->get_report_revision_list(array("revision_SN" => $revision_SN))->row_array();
     if (!$report_revision) {
         throw new Exception("無此報告修改單", ERROR_CODE);
     }
     $report_revision['test_outline'] = explode(',', $report_revision['test_outline']);
     $unsigned_admin_ID = array();
     //取的在該關已簽名的名單
     $signed_admins = $this->get_revision_checkpoint_list(array("revision_SN" => $report_revision['serial_no'], "checkpoint_ID" => $report_revision['checkpoint']))->result_array();
     $signed_admins = sql_column_to_key_value_array($signed_admins, "admin_ID");
     if ($report_revision['checkpoint'] == "technical_manager" || $report_revision['checkpoint'] == "report_signatory") {
         foreach ($report_revision['test_outline'] as $test_outline) {
             $signable_admins = $this->get_admin_privilege_list(array("privilege" => "revision_{$report_revision['checkpoint']}_{$test_outline}"))->result_array();
             $signable_admins = sql_column_to_key_value_array($signable_admins, "admin_ID");
             if (!array_in_array($signed_admins, $signable_admins)) {
                 //都還沒簽
                 $unsigned_admin_ID = array_merge($unsigned_admin_ID, $signable_admins);
             }
         }
     } else {
         $signable_admins = $this->get_admin_privilege_list(array("privilege" => "revision_{$report_revision['checkpoint']}"))->result_array();
         $signable_admins = sql_column_to_key_value_array($signable_admins, "admin_ID");
         if (!array_in_array($signed_admins, $signable_admins)) {
             //還沒簽
             $unsigned_admin_ID = array_merge($unsigned_admin_ID, $signable_admins);
         }
     }
     $unsigned_admin_ID = array_unique($unsigned_admin_ID);
     return $unsigned_admin_ID;
 }
Esempio n. 3
0
function loadExcel($filename, $pars)
{
    $pars_default = array('sheetIndex' => 0, 'headerKey' => FALSE, 'readColumn' => array());
    $pars = array_merge($pars_default, $pars);
    //    error_reporting(E_ALL);
    //    ini_set('display_errors', TRUE);
    //    ini_set('display_startup_errors', TRUE);
    require_once APPPATH . 'libraries/PHPExcel.php';
    $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
    $cacheSettings = array('memoryCacheSize' => '16MB');
    PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
    $objPHPExcel = new PHPExcel();
    $objReader = PHPExcel_IOFactory::createReaderForFile($filename);
    $objPHPExcel = $objReader->load($filename);
    $objPHPExcel->setActiveSheetIndex($pars['sheetIndex']);
    $objWorksheet = $objPHPExcel->getActiveSheet();
    $i = 0;
    $temp_rows = array();
    $temp_header = array();
    foreach ($objWorksheet->getRowIterator() as $row) {
        $cellIterator = $row->getCellIterator();
        $cellIterator->setIterateOnlyExistingCells(false);
        if ($pars['headerKey'] == FALSE) {
            //不用读取表头
            //            if( $i == 0 && $pars['includeHeader'] == FALSE ){
            //                $i++;
            //                continue;
            //            }
            $temp_row = array();
            foreach ($cellIterator as $cell) {
                $temp_row[] = trim($cell->getValue());
            }
            $temp_rows[] = $temp_row;
            $i++;
        } else {
            //以表头为键
            if ($i == 0) {
                foreach ($cellIterator as $cell) {
                    $temp_header[] = $cell->getValue();
                }
                //指定列头必须在excel中
                if (!array_in_array($temp_header, $pars['readColumn'])) {
                    return array();
                }
                $i++;
            } else {
                $temp_row = array();
                foreach ($cellIterator as $cell) {
                    $temp_row[] = $cell->getValue();
                }
                //$temp_rows[] = array_combine($temp_header, $temp_row);
                $all_row = array_combine($temp_header, $temp_row);
                if ($pars['readColumn']) {
                    $temp = array();
                    foreach ($all_row as $key => $val) {
                        if (in_array($key, $pars['readColumn'])) {
                            $temp[$key] = $val;
                        }
                    }
                    $temp_rows[] = $temp;
                } else {
                    $temp_rows[] = $all_row;
                }
                $i++;
            }
        }
    }
    return $temp_rows;
}
 /**
  * Field Render Function.
  *
  * Takes the vars and outputs the HTML for the field in the settings
  *
  * @since ReduxFramework 1.0.0
  */
 function render()
 {
     /*
      * So, in_array() wasn't doing it's job for checking a passed array for a proper value.
      * It's wonky.  It only wants to check the keys against our array of acceptable values, and not the key's
      * value.  So we'll use this instead.  Fortunately, a single no array value can be passed and it won't
      * take a dump.
      */
     if (!function_exists('array_in_array')) {
         function array_in_array($needle, $haystack)
         {
             //Make sure $needle is an array for foreach
             if (!is_array($needle)) {
                 $needle = array($needle);
             }
             //For each value in $needle, return TRUE if in $haystack
             foreach ($needle as $pin) {
                 //echo 'needle' . $pin;
                 if (in_array($pin, $haystack)) {
                     return true;
                 }
             }
             //Return FALSE if none of the values from $needle are found in $haystack
             return false;
         }
     }
     // No errors please
     $defaults = array('width' => true, 'height' => true, 'units_extended' => false, 'units' => 'px');
     $this->field = wp_parse_args($this->field, $defaults);
     $defaults = array('width' => '', 'height' => '', 'units' => 'px');
     $this->value = wp_parse_args($this->value, $defaults);
     /*
      * Acceptable values checks.  If the passed variable doesn't pass muster, we unset them
      * and reset them with default values to avoid errors.
      */
     // If units field has a value but is not an acceptable value, unset the variable
     if (isset($this->field['units']) && !array_in_array($this->field['units'], array('', false, '%', 'in', 'cm', 'mm', 'em', 'ex', 'pt', 'pc', 'px'))) {
         unset($this->field['units']);
     }
     //if there is a default unit value  but is not an accepted value, unset the variable
     if (isset($this->value['units']) && !array_in_array($this->value['units'], array('', '%', 'in', 'cm', 'mm', 'em', 'ex', 'pt', 'pc', 'px'))) {
         unset($this->value['units']);
     }
     /*
      * Since units field could be an array, string value or bool (to hide the unit field)
      * we need to separate our functions to avoid those nasty PHP index notices!
      */
     // if field units has a value and IS an array, then evaluate as needed.
     if (isset($this->field['units']) && !is_array($this->field['units'])) {
         //if units fields has a value but units value does not then make units value the field value
         if (isset($this->field['units']) && !isset($this->value['units']) || $this->field['units'] == false) {
             $this->value['units'] = $this->field['units'];
             // If units field does NOT have a value and units value does NOT have a value, set both to blank (default?)
         } else {
             if (!isset($this->field['units']) && !isset($this->value['units'])) {
                 $this->field['units'] = 'px';
                 $this->value['units'] = 'px';
                 // If units field has NO value but units value does, then set unit field to value field
             } else {
                 if (!isset($this->field['units']) && isset($this->value['units'])) {
                     $this->field['units'] = $this->value['units'];
                     // if unit value is set and unit value doesn't equal unit field (coz who knows why)
                     // then set unit value to unit field
                 } elseif (isset($this->value['units']) && $this->value['units'] !== $this->field['units']) {
                     $this->value['units'] = $this->field['units'];
                 }
             }
         }
         // do stuff based on unit field NOT set as an array
     } elseif (isset($this->field['units']) && is_array($this->field['units'])) {
         // nothing to do here, but I'm leaving the construct just in case I have to debug this again.
     }
     echo '<fieldset id="' . $this->field['id'] . '" class="redux-dimensions-container" data-id="' . $this->field['id'] . '">';
     // This used to be unit field, but was giving the PHP index error when it was an array,
     // so I changed it.
     echo '<input type="hidden" class="field-units" value="' . $this->value['units'] . '">';
     /**
               Width
              * */
     if ($this->field['width'] === true) {
         if (!empty($this->value['width']) && strpos($this->value['width'], $this->value['units']) === false) {
             $this->value['width'] = filter_var($this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
             if ($this->field['units'] !== false) {
                 $this->value['width'] .= $this->value['units'];
             }
         }
         echo '<div class="field-dimensions-input input-prepend">';
         echo '<span class="add-on"><i class="el-icon-resize-horizontal icon-large"></i></span>';
         echo '<input type="text" class="redux-dimensions-input redux-dimensions-width mini' . $this->field['class'] . '" placeholder="' . __('Width', 'redux-framework') . '" rel="' . $this->field['id'] . '-width" value="' . filter_var($this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . '">';
         echo '<input data-id="' . $this->field['id'] . '" type="hidden" id="' . $this->field['id'] . '-width" name="' . $this->field['name'] . '[width]' . $this->field['name_suffix'] . '" value="' . $this->value['width'] . '"></div>';
     }
     /**
               Height
              * */
     if ($this->field['height'] === true) {
         if (!empty($this->value['height']) && strpos($this->value['height'], $this->value['units']) === false) {
             $this->value['height'] = filter_var($this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
             if ($this->field['units'] !== false) {
                 $this->value['height'] .= $this->value['units'];
             }
         }
         echo '<div class="field-dimensions-input input-prepend">';
         echo '<span class="add-on"><i class="el-icon-resize-vertical icon-large"></i></span>';
         echo '<input type="text" class="redux-dimensions-input redux-dimensions-height mini' . $this->field['class'] . '" placeholder="' . __('height', 'redux-framework') . '" rel="' . $this->field['id'] . '-height" value="' . filter_var($this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . '">';
         echo '<input data-id="' . $this->field['id'] . '" type="hidden" id="' . $this->field['id'] . '-height" name="' . $this->field['name'] . '[height]' . $this->field['name_suffix'] . '" value="' . $this->value['height'] . '"></div>';
     }
     /**
               Units
             **/
     // If units field is set and units field NOT false then
     // fill out the options object and show it, otherwise it's hidden
     // and the default units value will apply.
     if (isset($this->field['units']) && $this->field['units'] !== false) {
         echo '<div class="select_wrapper dimensions-units" original-title="' . __('Units', 'redux-framework') . '">';
         echo '<select data-id="' . $this->field['id'] . '" data-placeholder="' . __('Units', 'redux-framework') . '" class="redux-dimensions redux-dimensions-units select' . $this->field['class'] . '" original-title="' . __('Units', 'redux-framework') . '" name="' . $this->field['name'] . '[units]' . $this->field['name_suffix'] . '">';
         //  Extended units, show 'em all
         if ($this->field['units_extended']) {
             $testUnits = array('px', 'em', 'rem', '%', 'in', 'cm', 'mm', 'ex', 'pt', 'pc');
         } else {
             $testUnits = array('px', 'em', 'rem', '%');
         }
         if ($this->field['units'] != "" && is_array($this->field['units'])) {
             $testUnits = $this->field['units'];
         }
         if (in_array($this->field['units'], $testUnits)) {
             echo '<option value="' . $this->field['units'] . '" selected="selected">' . $this->field['units'] . '</option>';
         } else {
             foreach ($testUnits as $aUnit) {
                 echo '<option value="' . $aUnit . '" ' . selected($this->value['units'], $aUnit, false) . '>' . $aUnit . '</option>';
             }
         }
         echo '</select></div>';
     }
     echo "</fieldset>";
 }
Esempio n. 5
0
 /**
  * Field Render Function.
  *
  * Takes the vars and outputs the HTML for the field in the settings
  *
  * @since ReduxFramework 1.0.0
  */
 function render()
 {
     /*
      * So, in_array() wasn't doing it's job for checking a passed array for a proper value.
      * It's wonky.  It only wants to check the keys against our array of acceptable values, and not the key's
      * value.  So we'll use this instead.  Fortunately, a single no array value can be passed and it won't
      * take a dump.
      */
     if (!function_exists('array_in_array')) {
         function array_in_array($needle, $haystack)
         {
             //Make sure $needle is an array for foreach
             if (!is_array($needle)) {
                 $needle = array($needle);
             }
             //For each value in $needle, return TRUE if in $haystack
             foreach ($needle as $pin) {
                 //echo 'needle' . $pin;
                 if (in_array($pin, $haystack)) {
                     return true;
                 }
             }
             //Return FALSE if none of the values from $needle are found in $haystack
             return false;
         }
     }
     // No errors please
     // Set field values
     $defaults = array('units' => '', 'mode' => 'padding', 'top' => true, 'bottom' => true, 'all' => false, 'left' => true, 'right' => true, 'units_extended' => false, 'display_units' => true);
     $this->field = wp_parse_args($this->field, $defaults);
     // Set default values
     $defaults = array('top' => '', 'right' => '', 'bottom' => '', 'left' => '', 'units' => 'px');
     $this->value = wp_parse_args($this->value, $defaults);
     /*
      * Acceptable values checks.  If the passed variable doesn't pass muster, we unset them
      * and reset them with default values to avoid errors.
      */
     // If units field has a value but is not an acceptable value, unset the variable
     if (isset($this->field['units']) && !array_in_array($this->field['units'], array('', false, '%', 'in', 'cm', 'mm', 'em', 'rem', 'ex', 'pt', 'pc', 'px'))) {
         unset($this->field['units']);
     }
     //if there is a default unit value  but is not an accepted value, unset the variable
     if (isset($this->value['units']) && !array_in_array($this->value['units'], array('', '%', 'in', 'cm', 'mm', 'em', 'rem', 'ex', 'pt', 'pc', 'px'))) {
         unset($this->value['units']);
     }
     if ($this->field['mode'] == "absolute") {
         $this->field['units'] = "";
         $this->value['units'] = "";
     }
     if ($this->field['units'] == false) {
         $this->value == "";
     }
     if (isset($this->field['mode']) && !in_array($this->field['mode'], array('margin', 'padding'))) {
         if ($this->field['mode'] == "absolute") {
             $absolute = true;
         }
         $this->field['mode'] = "";
     }
     $value = array('top' => isset($this->value[$this->field['mode'] . '-top']) ? filter_var($this->value[$this->field['mode'] . '-top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : filter_var($this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), 'right' => isset($this->value[$this->field['mode'] . '-right']) ? filter_var($this->value[$this->field['mode'] . '-right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : filter_var($this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), 'bottom' => isset($this->value[$this->field['mode'] . '-bottom']) ? filter_var($this->value[$this->field['mode'] . '-bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : filter_var($this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), 'left' => isset($this->value[$this->field['mode'] . '-left']) ? filter_var($this->value[$this->field['mode'] . '-left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : filter_var($this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
     // if field units has a value and is NOT an array, then evaluate as needed.
     if (isset($this->field['units']) && !is_array($this->field['units'])) {
         //if units fields has a value and is not empty but units value does not then make units value the field value
         if (isset($this->field['units']) && $this->field['units'] != "" && !isset($this->value['units']) || $this->field['units'] == false) {
             $this->value['units'] = $this->field['units'];
             // If units field does NOT have a value and units value does NOT have a value, set both to blank (default?)
         } else {
             if (!isset($this->field['units']) && !isset($this->value['units'])) {
                 $this->field['units'] = 'px';
                 $this->value['units'] = 'px';
                 // If units field has NO value but units value does, then set unit field to value field
             } else {
                 if (!isset($this->field['units']) && isset($this->value['units'])) {
                     // If Value is defined
                     $this->field['units'] = $this->value['units'];
                     // if unit value is set and unit value doesn't equal unit field (coz who knows why)
                     // then set unit value to unit field
                 } elseif (isset($this->value['units']) && $this->value['units'] !== $this->field['units']) {
                     $this->value['units'] = $this->field['units'];
                 }
             }
         }
         // do stuff based on unit field NOT set as an array
     } elseif (isset($this->field['units']) && is_array($this->field['units'])) {
         // nothing to do here, but I'm leaving the construct just in case I have to debug this again.
     }
     if (isset($this->field['units'])) {
         $value['units'] = $this->value['units'];
     }
     $this->value = $value;
     if (!empty($this->field['mode'])) {
         $this->field['mode'] = $this->field['mode'] . "-";
     }
     $defaults = array('top' => '', 'right' => '', 'bottom' => '', 'left' => '', 'units' => '');
     $this->value = wp_parse_args($this->value, $defaults);
     echo '<input type="hidden" class="field-units" value="' . $this->value['units'] . '">';
     if (isset($this->field['all']) && $this->field['all'] == true) {
         echo '<div class="field-spacing-input input-prepend"><span class="add-on"><i class="el-icon-fullscreen icon-large"></i></span><input type="text" class="redux-spacing-all redux-spacing-input mini' . $this->field['class'] . '" placeholder="' . __('All', 'redux-framework') . '" rel="' . $this->field['id'] . '-all" value="' . $this->value['top'] . '"></div>';
     }
     if ($this->field['top'] === true) {
         echo '<input type="hidden" class="redux-spacing-value" id="' . $this->field['id'] . '-top" name="' . $this->field['name'] . '[' . $this->field['mode'] . 'top]' . $this->field['name_suffix'] . '" value="' . $this->value['top'] . (!empty($this->value['top']) ? $this->value['units'] : '') . '">';
     }
     if ($this->field['right'] === true) {
         echo '<input type="hidden" class="redux-spacing-value" id="' . $this->field['id'] . '-right" name="' . $this->field['name'] . '[' . $this->field['mode'] . 'right]' . $this->field['name_suffix'] . '" value="' . $this->value['right'] . (!empty($this->value['right']) ? $this->value['units'] : '') . '">';
     }
     if ($this->field['bottom'] === true) {
         echo '<input type="hidden" class="redux-spacing-value" id="' . $this->field['id'] . '-bottom" name="' . $this->field['name'] . '[' . $this->field['mode'] . 'bottom]' . $this->field['name_suffix'] . '" value="' . $this->value['bottom'] . (!empty($this->value['bottom']) ? $this->value['units'] : '') . '">';
     }
     if ($this->field['left'] === true) {
         echo '<input type="hidden" class="redux-spacing-value" id="' . $this->field['id'] . '-left" name="' . $this->field['name'] . '[' . $this->field['mode'] . 'left]' . $this->field['name_suffix'] . '" value="' . $this->value['left'] . (!empty($this->value['left']) ? $this->value['units'] : '') . '">';
     }
     if (!isset($this->field['all']) || $this->field['all'] !== true) {
         /**
                       Top
                      * */
         if ($this->field['top'] === true) {
             echo '<div class="field-spacing-input input-prepend"><span class="add-on"><i class="el-icon-arrow-up icon-large"></i></span><input type="text" class="redux-spacing-top redux-spacing-input mini' . $this->field['class'] . '" placeholder="' . __('Top', 'redux-framework') . '" rel="' . $this->field['id'] . '-top" value="' . $this->value['top'] . '"></div>';
         }
         /**
                       Right
                      * */
         if ($this->field['right'] === true) {
             echo '<div class="field-spacing-input input-prepend"><span class="add-on"><i class="el-icon-arrow-right icon-large"></i></span><input type="text" class="redux-spacing-right redux-spacing-input mini' . $this->field['class'] . '" placeholder="' . __('Right', 'redux-framework') . '" rel="' . $this->field['id'] . '-right" value="' . $this->value['right'] . '"></div>';
         }
         /**
                       Bottom
                      * */
         if ($this->field['bottom'] === true) {
             echo '<div class="field-spacing-input input-prepend"><span class="add-on"><i class="el-icon-arrow-down icon-large"></i></span><input type="text" class="redux-spacing-bottom redux-spacing-input mini' . $this->field['class'] . '" placeholder="' . __('Bottom', 'redux-framework') . '" rel="' . $this->field['id'] . '-bottom" value="' . $this->value['bottom'] . '"></div>';
         }
         /**
                       Left
                      * */
         if ($this->field['left'] === true) {
             echo '<div class="field-spacing-input input-prepend"><span class="add-on"><i class="el-icon-arrow-left icon-large"></i></span><input type="text" class="redux-spacing-left redux-spacing-input mini' . $this->field['class'] . '" placeholder="' . __('Left', 'redux-framework') . '" rel="' . $this->field['id'] . '-left" value="' . $this->value['left'] . '"></div>';
         }
     }
     /**
               Units
              * */
     if ($this->field['units'] !== false && is_array($this->field['units']) && !isset($absolute) && $this->field['display_units'] == true) {
         echo '<div class="select_wrapper spacing-units" original-title="' . __('Units', 'redux-framework') . '">';
         echo '<select data-placeholder="' . __('Units', 'redux-framework') . '" class="redux-spacing redux-spacing-units select' . $this->field['class'] . '" original-title="' . __('Units', 'redux-framework') . '" name="' . $this->field['name'] . '[units]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '_units">';
         if ($this->field['units_extended']) {
             $testUnits = array('px', 'em', 'rem', '%', 'in', 'cm', 'mm', 'ex', 'pt', 'pc');
         } else {
             $testUnits = array('px', 'em', 'pt', 'rem', '%');
         }
         if ($this->field['units'] != "" || is_array($this->field['units'])) {
             //$testUnits = array($this->field['units']);
             $testUnits = $this->field['units'];
         }
         echo '<option></option>';
         if (in_array($this->field['units'], $testUnits)) {
             echo '<option value="' . $this->field['units'] . '" selected="selected">' . $this->field['units'] . '</option>';
         } else {
             foreach ($testUnits as $aUnit) {
                 echo '<option value="' . $aUnit . '" ' . selected($this->value['units'], $aUnit, false) . '>' . $aUnit . '</option>';
             }
         }
         echo '</select></div>';
     }
 }
Esempio n. 6
0
function geraXmlSistemas_pegafuncoes($perfil, $xml, $id_sistema, $dbh)
{
    global $esquemaadmin;
    xml_testaNum([$id_sistema]);
    $q = "select * from " . $esquemaadmin . "i3geoadmin_sistemasf where id_sistema = '{$id_sistema}'";
    $qtemas = $dbh->query($q);
    foreach ($qtemas as $row) {
        if ($row["perfil_funcao"] == "") {
            $mostra = true;
        } else {
            $perfilF = explode(" ", str_replace(",", " ", $row["perfil_funcao"]));
            $mostra = array_in_array($perfil, $perfilF);
        }
        if ($mostra) {
            $xml .= "<FUNCAO>\n";
            $xml .= " <NOMEFUNCAO>" . xmlTexto_prepara($row["nome_funcao"]) . "</NOMEFUNCAO>\n";
            $xml .= " <ABRIR>" . xmlTexto_prepara($row["abrir_funcao"]) . "</ABRIR>\n";
            $xml .= " <JANELAW>" . $row["w_funcao"] . "</JANELAW>\n";
            $xml .= " <JANELAH>" . $row["h_funcao"] . "</JANELAH>\n";
            $xml .= " <PERFIL>" . $row["perfil_funcao"] . "</PERFIL>\n";
            $xml .= "</FUNCAO>\n";
        }
    }
    return $xml;
}
 public function update_curriculum_class_state()
 {
     $this->load->model('curriculum_model');
     $this->load->model('curriculum/class_model');
     $this->load->model('curriculum/lesson_model');
     $this->load->model('user_model');
     $this->load->model('facility/booking_model');
     //取得課務員email
     $admins = $this->curriculum_model->get_admin_privilege_list(array("privilege" => "curriculum_super_admin"))->result_array();
     $admin_emails = sql_column_to_key_value_array($admins, "admin_email");
     $group_classes = $this->curriculum_model->get_class_list(array("class_reg_end_time_start" => date("Y-m-d 00:00:01", strtotime("-1day")), "class_reg_end_time_end" => date("Y-m-d 00:00:00"), "class_state" => "normal", "group_class_suite" => TRUE))->result_array();
     //加開的不用判斷
     foreach ($group_classes as $group_class) {
         //把相關課程都取出來
         $classes = $this->curriculum_model->get_class_list(array("course_ID" => $group_class['course_ID'], "class_code" => $group_class['class_code'], "class_state" => "normal"))->result_array();
         //判斷是否滿足大於等於最小開課人數
         $reg_num = $this->curriculum_model->get_reg_list(array("class_ID" => $group_class['class_ID']))->num_rows();
         if ($reg_num >= $group_class['class_min_participants']) {
             foreach ($classes as $class) {
                 //還要注意只開認證時,要排除正規課程未開的人員
                 //認證課程用特殊處理方式
                 $original_canceled_reg_nums = 0;
                 $original_canceled_reg_user_IDs = array();
                 if ($this->class_model->is_certification_class_only($class['class_type'])) {
                     //先取得原本沒開課的報名人數
                     $original_canceled_regs = $this->curriculum_model->get_reg_list(array("course_ID" => $class['course_ID'], "class_code" => $class['class_code'], "class_state" => "canceled", "group_class_suite" => TRUE));
                     $original_canceled_reg_nums = $original_canceled_regs->num_rows();
                     $original_canceled_reg_user_IDs = sql_result_to_column($original_canceled_regs->result_array(), "user_ID");
                 }
                 $regs = $this->curriculum_model->get_reg_list(array("class_ID" => $class['class_ID']))->result_array();
                 foreach ($regs as $reg) {
                     if (empty($class['class_max_participants']) || $reg['reg_rank'] - $original_canceled_reg_nums <= $class['class_max_participants']) {
                         if (!in_array($reg['user_ID'], $original_canceled_reg_user_IDs)) {
                             //正常開課,發信通知正取學員
                             $user_profile = $this->user_model->get_user_profile_list(array("user_ID" => $reg['user_ID']))->row_array();
                             $this->email->to($user_profile['email'])->cc($admin_emails);
                             $this->email->subject("成大微奈米科技研究中心 -課程系統通知- [正常開課]");
                             $this->email->message("{$user_profile['name']} 您好:<br>\r\n\t\t\t\t\t\t\t\t\t\t<br>\r\n\t\t\t\t\t\t\t\t\t\t本中心將預定於 {$class['class_start_time']}<br>\r\n\t\t\t\t\t\t\t\t\t\t開設 {$class['course_cht_name']} " . $this->curriculum_model->get_class_type_str($class['class_type']) . " 課程<br>\r\n\t\t\t\t\t\t\t\t\t\t您的報名順序為 正取{$reg['reg_rank']},請準時前往上課,謝謝。<br>\r\n\t\t\t\t\t\t\t\t\t\t日期:" . date("Y-m-d", strtotime($class['class_start_time'])) . "<br>\r\n\t\t\t\t\t\t\t\t\t\t時間:" . date("H:i:s", strtotime($class['class_start_time'])) . "<br>\r\n\t\t\t\t\t\t\t\t\t\t課程名稱:{$class['course_cht_name']}<br>\r\n\t\t\t\t\t\t\t\t\t\t地點:{$class['location_cht_name']}<br>\r\n\t\t\t\t\t\t\t\t\t\t授課者:{$class['prof_name']}<br>\r\n\t\t\t\t\t\t\t\t\t\t");
                             $this->email->send();
                         }
                     } else {
                         if (!in_array($reg['user_ID'], $original_canceled_reg_user_IDs)) {
                             //發信通知備取學員,請他改選其他同課程
                             $user_profile = $this->user_model->get_user_profile_list(array("user_ID" => $reg['user_ID']))->row_array();
                             $this->email->to($user_profile['email'])->cc($admin_emails);
                             $this->email->subject("成大微奈米科技研究中心 -課程系統通知- [備取未上]");
                             $this->email->message("{$user_profile['name']} 您好:<br>\r\n\t\t\t\t\t\t\t\t\t\t<br>\r\n\t\t\t\t\t\t\t\t\t\t本中心將預定於 {$class['class_start_time']}<br>\r\n\t\t\t\t\t\t\t\t\t\t開設 {$class['course_cht_name']} " . $this->curriculum_model->get_class_type_str($class['class_type']) . " 課程<br>\r\n\t\t\t\t\t\t\t\t\t\t您的報名順序為 備取" . ($reg['reg_rank'] - $class['class_max_participants']) . ",很遺憾截至目前為止您尚未遞補上本次課程<br>\r\n\t\t\t\t\t\t\t\t\t\t竭誠歡迎您盡速上本中心網站預約下一期的課程,以免向隅,謝謝。");
                             $this->email->send();
                         }
                     }
                 }
             }
         } else {
             foreach ($classes as $class) {
                 //確認選課人中是否有上個月沒開成的選課人
                 //先取得這次選課人
                 $regs = $this->curriculum_model->get_reg_list(array("class_ID" => $class['class_ID']))->result_array();
                 //再取得上個月未開成的選課人
                 $last_canceled_classes = $this->curriculum_model->get_class_list(array("class_state" => "canceled", "course_ID" => $class['course_ID'], "class_start_time" => date("Y-m-01 00:00:00", strtotime($class['class_start_time'] . " -1month")), "class_end_time" => date("Y-m-01 00:00:00", strtotime($class['class_start_time']))))->result_array();
                 $last_canceled_regs = $this->curriculum_model->get_reg_list(array("class_ID" => sql_column_to_key_value_array($last_canceled_classes, "class_ID")))->result_array();
                 if (array_in_array(sql_column_to_key_value_array($regs, "user_ID"), sql_column_to_key_value_array($last_canceled_regs, "user_ID"))) {
                     //還要注意只開認證時,要排除正規課程未開的人員
                     //認證課程用特殊處理方式
                     $original_canceled_reg_nums = 0;
                     $original_canceled_reg_user_IDs = array();
                     if ($this->class_model->is_certification_class_only($class['class_type'])) {
                         //先取得原本沒開課的報名人數
                         $original_canceled_regs = $this->curriculum_model->get_reg_list(array("course_ID" => $class['course_ID'], "class_code" => $class['class_code'], "class_state" => "canceled", "group_class_suite" => TRUE));
                         $original_canceled_reg_nums = $original_canceled_regs->num_rows();
                         $original_canceled_reg_user_IDs = sql_result_to_column($original_canceled_regs->result_array(), "user_ID");
                     }
                     //要強制開
                     foreach ($regs as $reg) {
                         if (empty($class['class_max_participants']) || $reg['reg_rank'] - $original_canceled_reg_nums <= $class['class_max_participants']) {
                             if (!in_array($reg['user_ID'], $original_canceled_reg_user_IDs)) {
                                 //正常開課,發信通知正取學員
                                 $user_profile = $this->user_model->get_user_profile_list(array("user_ID" => $reg['user_ID']))->row_array();
                                 $this->email->to($user_profile['email'])->cc($admin_emails);
                                 $this->email->subject("成大微奈米科技研究中心 -課程系統通知- [強制開課]");
                                 $this->email->message("{$user_profile['name']} 您好:<br>\r\n\t\t\t\t\t\t\t\t\t\t\t<br>\r\n\t\t\t\t\t\t\t\t\t\t\t本中心將預定於 {$class['class_start_time']}<br>\r\n\t\t\t\t\t\t\t\t\t\t\t開設 {$class['course_cht_name']} " . $this->curriculum_model->get_class_type_str($class['class_type']) . " 課程<br>\r\n\t\t\t\t\t\t\t\t\t\t\t因您於上個月報名此課程時人數未達開課人數而停開,故本月特此強制開成<br>\r\n\t\t\t\t\t\t\t\t\t\t\t您的報名順序為 正取{$reg['reg_rank']},請準時前往上課,謝謝。<br>\r\n\t\t\t\t\t\t\t\t\t\t\t日期:" . date("Y-m-d", strtotime($class['class_start_time'])) . "<br>\r\n\t\t\t\t\t\t\t\t\t\t\t時間:" . date("H:i:s", strtotime($class['class_start_time'])) . "<br>\r\n\t\t\t\t\t\t\t\t\t\t\t課程名稱:{$class['course_cht_name']}<br>\r\n\t\t\t\t\t\t\t\t\t\t\t地點:{$class['location_cht_name']}<br>\r\n\t\t\t\t\t\t\t\t\t\t\t授課者:{$class['prof_name']}<br>\r\n\t\t\t\t\t\t\t\t\t\t\t");
                                 $this->email->send();
                             }
                         } else {
                             if (!in_array($reg['user_ID'], $original_canceled_reg_user_IDs)) {
                                 //發信通知備取學員,請他改選其他同課程
                                 $user_profile = $this->user_model->get_user_profile_list(array("user_ID" => $reg['user_ID']))->row_array();
                                 $this->email->to($user_profile['email'])->cc($admin_emails);
                                 $this->email->subject("成大微奈米科技研究中心 -課程系統通知- [備取未上]");
                                 $this->email->message("{$user_profile['name']} 您好:<br>\r\n\t\t\t\t\t\t\t\t\t\t\t<br>\r\n\t\t\t\t\t\t\t\t\t\t\t本中心將預定於 {$class['class_start_time']}<br>\r\n\t\t\t\t\t\t\t\t\t\t\t開設 {$class['course_cht_name']} " . $this->curriculum_model->get_class_type_str($class['class_type']) . " 課程<br>\r\n\t\t\t\t\t\t\t\t\t\t\t您的報名順序為 備取" . ($reg['reg_rank'] - $class['class_max_participants']) . ",很遺憾截至目前為止您尚未遞補上本次課程<br>\r\n\t\t\t\t\t\t\t\t\t\t\t竭誠歡迎您盡速上本中心網站預約下一期的課程,以免向隅,謝謝。");
                                 $this->email->send();
                             }
                         }
                     }
                 } else {
                     //停開,人數不足
                     $this->curriculum_model->update_class(array("class_ID" => $class['class_ID'], "class_state" => "canceled"));
                     //發信通知授課者
                     $profs_ID = $this->class_model->get_class_profs_ID($class['class_ID']);
                     if (!empty($profs_ID)) {
                         $prof_profiles = $this->user_model->get_user_profile_list(array("user_ID" => $profs_ID))->result_array();
                         $this->email->to(sql_result_to_column($prof_profiles, "email"))->cc($admin_emails);
                         $this->email->subject("成大微奈米科技研究中心 -課程系統通知- [停開]");
                         $this->email->message("您好:<br>\r\n\t\t\t\t\t\t\t\t\t<br>\r\n\t\t\t\t\t\t\t\t\t本中心預定於 {$class['class_start_time']}<br>\r\n\t\t\t\t\t\t\t\t\t開設之 {$class['course_cht_name']} " . $this->curriculum_model->get_class_type_str($class['class_type']) . " 課程<br>\r\n\t\t\t\t\t\t\t\t\t因人數不足停開,請勿前來上課,特此通知,謝謝。");
                         $this->email->send();
                     }
                     //發信通知已選課學員
                     $users_ID = sql_result_to_column($regs, "user_ID");
                     if (!empty($users_ID)) {
                         $user_profiles = $this->user_model->get_user_profile_list(array("user_ID" => $users_ID))->result_array();
                         $this->email->to(sql_result_to_column($user_profiles, "email"))->cc($admin_emails);
                         $this->email->subject("成大微奈米科技研究中心 -課程系統通知- [停開]");
                         $this->email->message("您好:<br>\r\n\t\t\t\t\t\t\t\t\t<br>\r\n\t\t\t\t\t\t\t\t\t本中心預定於 {$class['class_start_time']}<br>\r\n\t\t\t\t\t\t\t\t\t開設之 {$class['course_cht_name']} " . $this->curriculum_model->get_class_type_str($class['class_type']) . " 課程<br>\r\n\t\t\t\t\t\t\t\t\t因人數不足停開,請勿前來上課,特此通知,謝謝。");
                         $this->email->send();
                     }
                     //把預約的儀器全部取消
                     $bookings = $this->curriculum_model->get_lesson_booking_map(array("class_ID" => $class['class_ID']))->result_array();
                     if ($bookings) {
                         $b_IDs = sql_result_to_column($bookings, "booking_ID");
                         $this->booking_model->del($b_IDs);
                     }
                 }
             }
         }
     }
     echo "DONE";
 }
/**
 * get church service authorisation
 * 
 * @return array 
 */
function churchservice_getAuthorization()
{
    global $auth;
    if (!isset($_SESSION["user"]->auth["churchservice"])) {
        return null;
    }
    $auth = $_SESSION["user"]->auth["churchservice"];
    $user_pid = $_SESSION["user"]->id;
    $res = null;
    // TODO: why not $res = array();
    $res["user_pid"] = $user_pid;
    if (user_access("view", "churchdb")) {
        $res["viewchurchdb"] = true;
    }
    if (user_access("administer persons", "churchcore")) {
        $res["administer persons"] = true;
    }
    if (isset($auth["view"])) {
        $res["read"] = true;
    }
    if (isset($auth["edit events"])) {
        $res["read"] = true;
        $res["write"] = true;
    }
    if (isset($auth["view history"])) {
        $res["viewhistory"] = true;
    }
    if (isset($auth["view history"])) {
        $res["viewhistory"] = true;
    }
    if (isset($auth["export data"])) {
        $res["export"] = true;
    }
    if (isset($auth["edit template"])) {
        $res["edit template"] = true;
    }
    if (isset($auth["edit masterdata"])) {
        $res["admin"] = true;
    }
    if (isset($auth["manage absent"])) {
        $res["manageabsent"] = true;
    }
    if (isset($auth["view facts"])) {
        $res["viewfacts"] = true;
    }
    if (isset($auth["export facts"])) {
        $res["exportfacts"] = true;
    }
    if (isset($auth["edit facts"])) {
        $res["editfacts"] = true;
        $res["viewfacts"] = true;
    }
    if (isset($auth["view song"])) {
        if (isset($auth["view songcategory"])) {
            //use this? if (isset($auth["view song"]) && isset($auth["view songcategory"]))
            $res["viewsong"] = true;
            $res["viewsongcategory"] = $auth["view songcategory"];
        }
    }
    if (isset($auth["edit song"])) {
        if (isset($auth["view songcategory"])) {
            $res["viewsong"] = true;
            $res["editsong"] = true;
            $res["viewsongcategory"] = $auth["view songcategory"];
        }
    }
    if (isset($auth["view servicegroup"])) {
        $res_view = $auth["view servicegroup"];
    } else {
        $res_view = array();
    }
    //check if user is in one of the groups of servicegroup
    $arr = churchcore_getTableData("cs_servicegroup", "sortkey");
    $myTnGroups = churchdb_getMyGroups($user_pid, true, false);
    $myLdGroups = churchdb_getMyGroups($user_pid, true, true);
    foreach ($arr as $grp) {
        $groups = churchservice_getGroupsOfServiceGroup($grp->id);
        if ($grp->viewall_yn == 1 || array_in_array($groups, $myTnGroups)) {
            $res_view[$grp->id] = true;
        }
    }
    $res["viewgroup"] = $res_view;
    if (isset($auth["edit servicegroup"])) {
        $res["editgroup"] = $auth["edit servicegroup"];
        // Copy edit permission to view permissions!
        // TODO: is there a difference to $res["viewgroup"] = $auth["edit servicegroup"]?
        foreach ($auth["edit servicegroup"] as $key => $a) {
            $res["viewgroup"][$key] = $a;
        }
    } else {
        $res["editgroup"] = array();
    }
    // check if user is leader or at least member of a group
    // this is important for editing entries
    $arr = churchcore_getTableData("cs_service", "sortkey");
    $res_member = array();
    $res_leader = array();
    $res_edit = array();
    foreach ($arr as $service) {
        $groups = churchservice_getGroupsOfService($service->id);
        if (array_in_array($groups, $myLdGroups)) {
            $res_member[$service->id] = true;
            $res_leader[$service->id] = true;
        } else {
            if (array_in_array($groups, $myTnGroups)) {
                $res_member[$service->id] = true;
            }
        }
        // check edit permission for service group
        if (isset($res["editgroup"][$service->servicegroup_id])) {
            $res_edit[$service->id] = true;
        }
    }
    $res["memberservice"] = $res_member;
    $res["leaderservice"] = $res_leader;
    $res["editservice"] = $res_edit;
    if (isset($auth["view agenda"])) {
        $res["view agenda"] = $auth["view agenda"];
    }
    if (isset($auth["edit agenda"])) {
        $res["edit agenda"] = $auth["edit agenda"];
        // copy permissions to view
        // TODO: is there a difference to $res["edit_agenda"] = $res["view agenda"]?
        foreach ($res["edit agenda"] as $key => $edit) {
            $res["view agenda"][$key] = $edit;
        }
    }
    if (isset($auth["edit agenda templates"])) {
        $res["edit agenda templates"] = $auth["edit agenda templates"];
    }
    $auth = $res;
    //$auth is global; TODO: why not use $auth all the way rather then the additional $res?
    return $res;
}