示例#1
0
/**
 * Smarty {occ} function plugin
 *
 * Type:     function<br>
 * Name:     occ<br>
 * Date:     Feb 17, 2003<br>
 * Purpose:  return a <br>
 * Input:<br>
 *         - label
 *         - element
 *         - separator
 *         - class
 *
 * Examples:
 * <pre>
 * {occ label=AUTOR element=$doc->au separator=; class=author}
 * </pre>
 * @author   Vinicius Andrade <viniciusdeandrade at gmail dot com>
 * @version  0.1
 * @param array
 * @param Smarty
 * @return string
 */
function smarty_function_occ($params, &$smarty)
{
    $output = "";
    $element = $params['element'];
    $text_transform = $params['text_transform'];
    if (!isset($element) || $element == '' || count($element) == 0) {
        return;
    }
    $element = $params['element'];
    if (isset($params['class'])) {
        $output .= "<div class=\"" . $params['class'] . "\">\n";
    }
    if (isset($params['label'])) {
        $output .= $params['label'] . ": ";
    }
    if (isset($params['span'])) {
        $output .= "<span>";
    }
    if (is_array($element)) {
        for ($occ = 0; $occ < count($element); $occ++) {
            if ($occ > 0) {
                $output .= $params['separator'] . " ";
            }
            if (isset($params['translation'])) {
                $text = smarty_function_occ_translate($element[$occ], $params['suffix'], $params['translation']);
            } else {
                $text = $element[$occ];
            }
            if (isset($text_transform) && $text_transform != '') {
                if ($text_transform == 'lowercase') {
                    $text = strtolower_utf8($text);
                } elseif ($text_transform == 'uppercase') {
                    $text = strtoupper_utf8($text);
                } elseif ($text_transform == 'capitalize') {
                    $text = capitalize_utf8($text);
                }
            }
            $output .= $text;
        }
    } else {
        if (isset($params['translation'])) {
            $output .= smarty_function_occ_translate($element, $params['suffix'], $params['translation']);
        } else {
            $output .= $element;
        }
    }
    if (isset($params['span'])) {
        $output .= "</span>";
    }
    if (isset($params['class'])) {
        $output .= "</div>\n";
    }
    return $output;
}
function ProcessData($strData, $Process)
{
    global $currencies, $posted_currencies, $rw_xtra_jrnl_defs;
    //echo 'process = ' . $Process . ' and posted cur = '; print_r($posted_currencies); echo '<br />';
    switch ($Process) {
        case "uc":
            return strtoupper_utf8($strData);
        case "lc":
            return strtolower_utf8($strData);
        case "neg":
            return -$strData;
        case "rnd2d":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return number_format(round($strData, 2), 2, '.', '');
            }
        case "rnd_dec":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return $currencies->format($strData);
            }
        case "rnd_pre":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return $currencies->precise($strData);
            }
        case "def_cur":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return $currencies->format_full($strData, true, DEFAULT_CURRENCY, 1, 'fpdf');
            }
        case "null_dcur":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return !$strData ? '' : $currencies->format_full($strData, true, DEFAULT_CURRENCY, 1, 'fpdf');
            }
        case "posted_cur":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return $currencies->format_full($strData, true, $posted_currencies['currencies_code'], $posted_currencies['currencies_value'], 'fpdf');
            }
        case "null_pcur":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return !$strData ? '' : $currencies->format_full($strData, true, $posted_currencies['currencies_code'], $posted_currencies['currencies_value'], 'fpdf');
            }
        case "dlr":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return '$ ' . number_format(round($strData, 2), 2);
            }
        case "euro":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return chr(128) . ' ' . number_format(round($strData, 2), 2);
            }
            // assumes standard FPDF fonts
        // assumes standard FPDF fonts
        case "n2wrd":
            return value_to_words_en_us($strData);
            // for checks primarily
        // for checks primarily
        case "terms":
            return gen_terms_to_language($strData, $short = true, $type = 'ar');
        case "date":
            return gen_spiffycal_db_date_short($strData);
        case "null-dlr":
            return !$strData ? '' : '$ ' . number_format($strData, 2);
        case "ordr_qty":
            return pull_order_qty($strData);
        case "branch":
            return rw_get_branch_name($strData);
        case "rep_id":
            return rw_get_user_name($strData);
        case "ship_name":
            return rw_get_ship_name($strData);
        case 'j_desc':
            return isset($rw_xtra_jrnl_defs[$strData]) ? $rw_xtra_jrnl_defs[$strData] : $strData;
        case 'yesBno':
            return $strData ? TEXT_YES : '';
        case 'printed':
            return $strData ? '' : TEXT_DUPLICATE;
    }
    $processed_value = false;
    if (function_exists('rw_extra_processing')) {
        $processed_value = rw_extra_processing($strData, $Process);
    }
    return $processed_value === false ? $strData : $processed_value;
    // do nothing if Process not recognized
}
示例#3
0
function ProcessData($strData, $Process)
{
    global $loaded_modules;
    //echo 'process = ' . $Process . ' and posted cur = '; print_r($posted_currencies); echo '<br />';
    switch ($Process) {
        case "uc":
            return strtoupper_utf8($strData);
        case "lc":
            return strtolower_utf8($strData);
        case "neg":
            return -$strData;
        case "n2wrd":
            return value_to_words_en_us($strData);
        case "rnd2d":
            if (!is_numeric($strData)) {
                return $strData;
            }
            return number_format(round($strData, 2), 2, '.', '');
        case "date":
            return gen_locale_date($strData);
        case "null-dlr":
            return (double) $strData == 0 ? '' : '$ ' . number_format($strData, 2);
        case "dlr":
            if (!is_numeric($strData)) {
                return $strData;
            }
            return '$ ' . number_format(round($strData, 2), 2);
        case "euro":
            if (!is_numeric($strData)) {
                return $strData;
            }
            return chr(128) . ' ' . number_format(round($strData, 2), 2);
            // assumes standard FPDF fonts
        // assumes standard FPDF fonts
        case 'yesBno':
            return $strData ? TEXT_YES : '';
        case 'blank':
            return '';
        case 'printed':
            return $strData ? '' : TEXT_DUPLICATE;
    }
    // now try loaded modules for processing
    foreach ($loaded_modules as $mod) {
        $mod_function = "pf_process_" . $mod;
        if (function_exists($mod_function)) {
            $strData = $mod_function($strData, $Process);
        }
    }
    if (function_exists('pf_extra_process')) {
        $strData = pf_extra_process($strData, $Process);
    }
    return $strData;
}
示例#4
0
function ucfirst_utf8($string)
{
    $firstChar = substr($string, 0, 1);
    $then = substr($string, 1, strlen($string) - 1);
    return strtoupper_utf8($firstChar) . $then;
}
示例#5
0
 public function Test()
 {
     $d = new MainController();
     $f = FuncControllers::getFunc();
     if (isset($_SESSION["clientid"])) {
         $clientid = $_SESSION["clientid"];
     }
     $debug = 0;
     if (isset($_GET["save"])) {
         $pid = $f->m_quotes($_GET["pid"]);
         if (isset($_GET["panels"])) {
             $panels = $f->m_quotes(substr($_GET["panels"], 0, -1));
         }
         if (isset($_GET["surname"])) {
             $surname = strtoupper_utf8($f->m_quotes($_GET["surname"]));
             $surname = preg_replace("/([\\s\\x{0}\\x{0B}]+)/i", " ", trim($surname));
         }
         if (isset($_GET["name"])) {
             $name = strtoupper_utf8($f->m_quotes($_GET["name"]));
             $name = preg_replace("/([\\s\\x{0}\\x{0B}]+)/i", " ", trim($name));
         }
         if (isset($_GET["namepatr"])) {
             $namepatr = strtoupper_utf8($f->m_quotes($_GET["namepatr"]));
             $namepatr = preg_replace("/([\\s\\x{0}\\x{0B}]+)/i", " ", trim($namepatr));
         }
         if (isset($_GET["doctor"])) {
             $doctor = strtoupper_utf8($f->m_quotes($_GET["doctor"]));
         }
         if (isset($_GET["policy"])) {
             $policy = strtoupper_utf8($f->m_quotes($_GET["policy"]));
         }
         if (isset($_GET["insurer"])) {
             $insurer = strtoupper_utf8($f->m_quotes($_GET["insurer"]));
         }
         if ($insurer == "") {
             $insurer = "N/A";
         }
         if (isset($_GET["insurerid"])) {
             $insurerid = strtoupper_utf8($f->m_quotes($_GET["insurerid"]));
         }
         if ($insurerid == "") {
             $insurerid = "6";
         }
         if (isset($_GET["gender"])) {
             $gender = $f->m_quotes($_GET["gender"]);
         }
         switch ($gender) {
             case -1:
                 $gender = "";
                 break;
             case 1:
                 $gender = "M";
                 break;
             case 2:
                 $gender = "F";
                 break;
         }
         if (isset($_GET["cito"])) {
             $cito = $f->m_quotes($_GET["cito"]);
         }
         if (isset($_GET["preg"])) {
             $pregnancy = $f->m_quotes($_GET["preg"]);
         }
         switch ($pregnancy) {
             case -1:
                 $pregnancy = "";
                 break;
         }
         if (isset($_GET["phase"])) {
             $phase = $f->m_quotes($_GET["phase"]);
         }
         switch ($phase) {
             case "-1":
                 $phase = "";
                 break;
         }
         if (isset($_GET["dt_bday"])) {
             $dt_bday = $f->m_quotes(date("Y/n/j", strtotime($_GET["dt_bday"])));
         }
         if (isset($_GET["comments"])) {
             $comments = $f->m_quotes($_GET["comments"]);
         }
         if (isset($_GET["dt_catched"])) {
             $dt_take = $f->m_quotes(date("Y/n/j G:i", strtotime($_GET["dt_catched"])));
         }
         //$dt_take = explode(" ", $f->m_quotes(date("Y/m/d G:i", strtotime($_GET["dt_catched"]))));
         if (isset($_GET["diagnosis"])) {
             $diagnosis = $f->m_quotes($_GET["diagnosis"]);
         }
         if (isset($_GET["phone"])) {
             $phone = $f->m_quotes($_GET["phone"]);
         }
         if (isset($_GET["diuresis"])) {
             $diuresis = $f->m_quotes(trim($_GET["diuresis"]) * 1.0);
         }
         if (isset($_GET["antibio"])) {
             $antibiot = "Y";
             if (isset($_GET["antibiotics"])) {
                 $antibiotics = $f->m_quotes($_GET["antibiotics"]);
             }
             if (isset($_GET["dt_biostart"])) {
                 $dt_biostart = $f->m_quotes(date("Y/n/j", strtotime($_GET["dt_biostart"])));
             }
             if (isset($_GET["dt_bioend"])) {
                 $dt_bioend = $f->m_quotes(date("Y/n/j", strtotime($_GET["dt_bioend"])));
             }
         }
         if (isset($_GET["passport_series"])) {
             $passport_series = $f->m_quotes($_GET["passport_series"]);
         }
         if (isset($_GET["passport_number"])) {
             $passport_number = $f->m_quotes($_GET["passport_number"]);
         }
         if (isset($_GET["email"])) {
             $email = $f->m_quotes($_GET["email"]);
         }
         if (isset($_GET["department"])) {
             $department = $f->m_quotes($_GET["department"]);
         }
         if (isset($_GET["address"])) {
             $address = $f->m_quotes($_GET["address"]);
         }
         if (isset($_GET["weight"])) {
             $weight = $f->m_quotes($_GET["weight"]);
         }
         if (isset($_GET["height"])) {
             $height = $f->m_quotes($_GET["height"]);
         }
         if (isset($_GET["tube"])) {
             $tube = $f->m_quotes($_GET["tube"]);
         }
         if (isset($_GET["glass"])) {
             $glass = $f->m_quotes($_GET["glass"]);
         }
         if (isset($_GET["card"])) {
             $card = $f->m_quotes($_GET["card"]);
         }
         if (isset($_GET["organisation"])) {
             $organisation = $f->m_quotes($_GET["organisation"]);
         } else {
             $organisation = '';
         }
         $vsql = "select folderno from n_registration ('" . $surname . "','" . $name . "','" . $namepatr . "','" . $gender . "','" . $dt_take . "','" . $dt_bday . "', null, '" . $phase . "', '" . $pregnancy . "', '" . $cito . "', " . $clientid . ",'" . $doctor . "','" . $policy . "','" . $insurer . "','" . $diuresis . "','" . $diagnosis . "','" . $antibiot . "','" . $antibiotics . "','" . $dt_biostart . "','" . $dt_bioend . "','" . $address . "', null,'" . $panels . "','" . $comments . "');";
         $vsql = str_replace("''", "null", $vsql);
         $stmt = $d->DBquery->getJsonMainListXSL($vsql);
         print_r($stmt);
         /*
                     if ($stmt === false) echo "Error in executing query.</br>"; else {
                         $row = ibase_fetch_row($stmt);
                         $folderno = $row[0];
                         $now = date("d.m.Y");
         
                         if (isset($_GET["aisorder"]) && trim($_GET["aisorder"]) !== '') $aisorder = $f->m_quotes($_GET["aisorder"]); else $aisorder = $folderno;
         
                         $vsql = "UPDATE FOLDERS SET INSURER = '" . $insurer . "', LOGUSER = '******', LOGDATE = '" . $now . "', CARD = '" . $card . "', GLASS = '" . $glass . "', TUBE = '" . $tube . "', PHONE = '" . $phone . "', EMAIL = '" . $email . "', WEIGHT = '" . $weight . "', HEIGHT = '" . $height . "', PASSPORT_SERIES = '" . $passport_series . "', PASSPORT_NUMBER = '" . $passport_number . "', DEPARTMENT = '" . $department . "', ORGANISATION = '" . $organisation . "', AISORDER = '" . $aisorder . "' WHERE FOLDERNO = '" . $folderno . "'";
                         $vsql = str_replace("''", "null", $vsql);
                         $stmt = ib_query($vsql);
                         if ($stmt === false) echo "Error in executing query.</br>";
         
                         foreach (explode(",", $panels) as $x) {
                             if (isset($_GET[str_replace(".", "_", $x)])) {
                                 $vsql = "select fc.id from foldercontainers fc inner join orders ord on ord.folderno = fc.folderno " .
                                     "inner join ordtask o on o.containerid = fc.id and ord.id = o.ordersid " .
                                     "inner join panels p on p.id = ord.panelid " .
                                     "where fc.folderno ='" . $folderno . "' AND p.code = '" . $x . "'";
                                 $stmt = ib_query($vsql);
                                 if ($stmt === false) echo "Error in executing query.</br>";
                                 $row = ibase_fetch_row($stmt);
                                 $vsql = "update foldercontainers set mattypeid = " . $_GET[str_replace(".", "_", $x)] . " WHERE id = " . $row[0];
                                 $stmt = ib_query($vsql);
                                 if ($stmt === false) echo "Error in executing query.</br>";
                             }
                         }
                     }
         
                     if ($debug == 1) {
                         echo "<!-- -------------- ОТЛАДОЧНАЯ ИНФОРМАЦИЯ --------------<br/>";
                         echo "Дата сбора: " . $dt_take . "<br/>";
                         echo "Фамилия: " . $surname . "<br/>";
                         echo "Имя: " . $name . "<br/>";
                         echo "Отчество: " . $namepatr . "<br/>";
                         echo "Доктор: " . $doctor . "<br/>";
                         echo "Полис: " . $policy . "<br/>";
                         echo "Страховая: '" . $insurer . "'(" . $insurerid . ")<br/>";
                         echo "Пол: " . $gender . "<br/>";
                         echo "Срочность: " . $cito . "<br/>";
                         echo "Срок беременности: " . $pregnancy . "<br/>";
                         echo "Фаза: " . $phase . "<br/>";
                         echo "Дата рождения: " . $dt_bday . "<br/>";
                         echo "Комментарий: " . $comments . "<br/>";
                         echo "Диагноз: " . $diagnosis . "<br/>";
                         echo "Телефон: " . $phone . "<br/>";
                         echo "Диурез: " . $diuresis . "<br/>";
                         echo "Антибиотики начало: " . $dt_biostart . "<br/>";
                         echo "Антибиотики конец: " . $dt_bioend . "<br/>";
                         echo "Серия паспорта: " . $passport_series . "<br/>";
                         echo "Номер паспорта: " . $passport_number . "<br/>";
                         echo "E-mail: " . $email . "<br/>";
                         echo "Препарат: " . $antibiotics . "<br/>";
                         echo "Отделение: " . $department . "<br/>";
                         echo "Адрес: " . $address . "<br/>";
                         echo "КОД ЛПУ: " . $clientid . "<br/>";
                         echo "ПАНЕЛИ: " . $panels . "<br/>";
                         echo "Вес: " . $weight . "<br/>";
                         echo "Рост: " . $height . "<br/>";
                         echo "№ пробирки: " . $tube . "<br/>";
                         echo "№ стекла: " . $glass . "<br/>";
                         echo "-------------- ОТЛАДОЧНАЯ ИНФОРМАЦИЯ --------------<br/><br/> -->";
                     } */
         // echo "<script>$('#folderno').html('" . $folderno . "');</script>";
         // echo "<img style=\"vertical-align: inherit; margin:0px; border:0\" src=\"images/ok.jpg\" /><b>Заявка была успешно сохранена под номером #" . $folderno . "</b>";
     }
     // return View::make('test');
 }