Ejemplo n.º 1
0
 function date_for_humans($time, $now = null)
 {
     $time = date_to_timestamp($time);
     if ($now) {
         $now = date_to_timestamp($now);
         $now = \Carbon\Carbon::createFromTimestamp($now);
     }
     $r = \Carbon\Carbon::createFromTimestamp($time)->diffForHumans($now);
     $r = str_replace(' seconds', '秒', $r);
     $r = str_replace(' minutes', '分钟', $r);
     $r = str_replace(' hours', '小时', $r);
     $r = str_replace(' days', '天', $r);
     $r = str_replace(' weeks', '周', $r);
     $r = str_replace(' months', '个月', $r);
     $r = str_replace(' years', '年', $r);
     $r = str_replace(' second', '秒', $r);
     $r = str_replace(' minute', '分钟', $r);
     $r = str_replace(' hour', '小时', $r);
     $r = str_replace(' day', '天', $r);
     $r = str_replace(' week', '周', $r);
     $r = str_replace(' month', '个月', $r);
     $r = str_replace(' year', '年', $r);
     $r = str_replace(' from now', '后', $r);
     $r = str_replace(' ago', '前', $r);
     $r = str_replace(' after', '后', $r);
     $r = str_replace(' before', '前', $r);
     return $r;
 }
Ejemplo n.º 2
0
 function testDate_to_Timestamp()
 {
     $this->assertEquals("20010914120000", date_to_timestamp("14", "9", "2001"));
     $this->assertEquals("20011914120000", date_to_timestamp("14", "19", "2001"));
     $this->assertEquals("20010908120000", date_to_timestamp("08", "9", "2001"));
     $this->assertEquals("20010907120000", date_to_timestamp("7", "9", "2001"));
     $this->assertEquals("20010907120000", date_to_timestamp("07", "09", "2001"));
 }
Ejemplo n.º 3
0
 protected function _get_mantis_attr($attr_name)
 {
     if ($attr_name == 'reporter_id') {
         return User::get_mantis_id_from_url($this->rsrc_data['reporter']);
     } elseif ($attr_name == 'handler_id') {
         return $this->rsrc_data['handler'] ? User::get_mantis_id_from_url($this->rsrc_data['handler']) : 0;
     } elseif ($attr_name == 'duplicate_id') {
         return $this->rsrc_data['duplicate'] ? Bug::get_mantis_id_from_url($this->rsrc_data['duplicate']) : 0;
     } elseif (in_array($attr_name, array('priority', 'severity', 'reproducibility', 'status', 'resolution', 'projection', 'eta'))) {
         return get_string_to_enum(config_get($attr_name . "_enum_string"), $this->rsrc_data[$attr_name]);
     } elseif ($attr_name == 'date_submitted' || $attr_name == 'last_updated') {
         return date_to_timestamp($this->rsrc_data[$attr_name]);
     } elseif ($attr_name == 'view_state') {
         return $this->rsrc_data['private'] ? VS_PRIVATE : VS_PUBLIC;
     } elseif (in_array($attr_name, Bug::$mantis_attrs)) {
         return $this->rsrc_data[$attr_name];
     }
 }
Ejemplo n.º 4
0
                <div class="col-md-10">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="field-box">
                                <label>Start date:</label>
                                <input id="start_date" name="start_date" class="form-control input-datepicker" type="text" data-date-minviewmode="months" data-date-viewmode="years" data-date-format="mm/yyyy" value="<?php 
echo timestamp_to_date(set_value('start_date', $company->start_date));
?>
">
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="field-box">
                                <label>End date:</label>
                                <input id="end_date" name="end_date" class="form-control input-datepicker" type="text" data-date-minviewmode="months" data-date-viewmode="years" data-date-format="mm/yyyy" value="<?php 
$end = $company->end_date ? $company->end_date : date_to_timestamp($company->end_date);
echo timestamp_to_date(set_value('end_date', $end));
?>
">
                                <p>Leave this field empty if you are still working here.</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <button type="submit" class="btn btn-default">Save</button>
                </div>
            </div>
            <?php 
Ejemplo n.º 5
0
function ListOutput($result, $column_names, $singular = '', $plural = '', $link = false, $group = false, $options = false, $for_window = '')
{
    if (!isset($options['save'])) {
        $options['save'] = true;
    }
    if (!isset($options['print'])) {
        $options['print'] = true;
    }
    if (!isset($options['search'])) {
        $options['search'] = true;
    }
    if (!isset($options['center'])) {
        $options['center'] = true;
    }
    if (!isset($options['count'])) {
        $options['count'] = true;
    }
    if (!isset($options['sort'])) {
        $options['sort'] = true;
    }
    if (!$link) {
        $link = array();
    }
    if (isset($_REQUEST['page'])) {
        if ($_REQUEST['list_type'] == $singular) {
            $Request_page = $_REQUEST['page'];
        }
    }
    if (!isset($options['add'])) {
        if (!AllowEdit() || $_REQUEST['_openSIS_PDF']) {
            if ($link) {
                unset($link['add']);
                unset($link['remove']);
            }
        }
    }
    // PREPARE LINKS ---
    $result_count = $display_count = count($result);
    $num_displayed = 100000;
    $extra = "page={$_REQUEST['page']}&LO_sort={$_REQUEST['LO_sort']}&LO_direction={$_REQUEST['LO_direction']}&LO_search=" . urlencode($_REQUEST['LO_search']);
    $tmp_REQUEST = $_REQUEST;
    unset($tmp_REQUEST['page']);
    unset($tmp_REQUEST['LO_sort']);
    unset($tmp_REQUEST['LO_direction']);
    unset($tmp_REQUEST['LO_search']);
    unset($tmp_REQUEST['remove_prompt']);
    unset($tmp_REQUEST['remove_name']);
    unset($tmp_REQUEST['LO_save']);
    unset($tmp_REQUEST['PHPSESSID']);
    //$PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
    $PHP_tmp_SELF = str_replace('>', '', PreparePHP_SELF($tmp_REQUEST));
    // END PREPARE LINKS ---
    // UN-GROUPING
    $group_count = count($group);
    if (!is_array($group)) {
        $group_count = false;
    }
    //$side_color = Preferences('COLOR');
    $side_color = 'class=odd';
    if ($group_count && $result_count) {
        $color = 'class=even';
        $group_result = $result;
        unset($result);
        $result[0] = '';
        foreach ($group_result as $item1) {
            if ($group_count == 1) {
                if ($color == 'class=even') {
                    $color = $side_color;
                } else {
                    $color = 'class=even';
                }
            }
            foreach ($item1 as $item2) {
                if ($group_count == 1) {
                    $i++;
                    if (count($group[0]) && $i != 1) {
                        foreach ($group[0] as $column) {
                            $item2[$column] = str_replace('<!-- <!--', '<!--', '<!-- ' . str_replace('-->', '--><!--', $item2[$column])) . ' -->';
                        }
                    }
                    $item2['row_color'] = $color;
                    $result[] = $item2;
                } else {
                    if ($group_count == 2) {
                        if ($color == 'class=even') {
                            $color = $side_color;
                        } else {
                            $color = 'class=even';
                        }
                    }
                    foreach ($item2 as $item3) {
                        if ($group_count == 2) {
                            $i++;
                            if (count($group[0]) && $i != 1) {
                                foreach ($group[0] as $column) {
                                    $item3[$column] = '<!-- ' . $item3[$column] . ' -->';
                                }
                            }
                            if (count($group[1]) && $i != 1) {
                                foreach ($group[1] as $column) {
                                    $item3[$column] = '<!-- ' . $item3[$column] . ' -->';
                                }
                            }
                            $item3['row_color'] = $color;
                            $result[] = $item3;
                        } else {
                            if ($group_count == 3) {
                                if ($color == 'class=even') {
                                    $color = $side_color;
                                } else {
                                    $color = 'class=even';
                                }
                            }
                            foreach ($item3 as $item4) {
                                if ($group_count == 3) {
                                    $i++;
                                    if (count($group[2]) && $i != 1) {
                                        foreach ($group[2] as $column) {
                                            unset($item4[$column]);
                                        }
                                    }
                                    $item4['row_color'] = $color;
                                    $result[] = $item4;
                                }
                            }
                        }
                    }
                }
            }
            $i = 0;
        }
        unset($result[0]);
        $result_count = count($result);
        unset($_REQUEST['LO_sort']);
    }
    // END UN-GROUPING
    $_LIST['output'] = true;
    // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---
    if ($_LIST['output'] != false) {
        if ($result_count != 0) {
            $count = 0;
            $remove = count($link['remove']['variables']);
            $cols = count($column_names);
            // HANDLE SEARCHES ---
            if ($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search'] != 'Search') {
                $_REQUEST['LO_search'] = $search_term = str_replace('\\\\"', '"', $_REQUEST['LO_search']);
                $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*', '', strtolower($search_term));
                if (substr($search_term, 0, 0) != '"' && substr($search_term, -1) != '"') {
                    $search_term = ereg_replace('"', '', $search_term);
                    while ($space_pos = strpos($search_term, ' ')) {
                        $terms[strtolower(substr($search_term, 0, $space_pos))] = 1;
                        $search_term = substr($search_term, $space_pos + 1);
                    }
                    $terms[trim($search_term)] = 1;
                } else {
                    $search_term = ereg_replace('"', '', $search_term);
                    $terms[trim($search_term)] = 1;
                }
                unset($terms['of']);
                unset($terms['the']);
                unset($terms['a']);
                unset($terms['an']);
                unset($terms['in']);
                foreach ($result as $key => $value) {
                    $values[$key] = 0;
                    foreach ($value as $name => $val) {
                        $val = ereg_replace('[^a-zA-Z0-9 _]+', '', strtolower($val));
                        if (strtolower($_REQUEST['LO_search']) == $val) {
                            $values[$key] += 25;
                        }
                        foreach ($terms as $term => $one) {
                            if (ereg($term, $val)) {
                                $values[$key] += 3;
                            }
                        }
                    }
                    if ($values[$key] == 0) {
                        unset($values[$key]);
                        unset($result[$key]);
                        $result_count--;
                        $display_count--;
                    }
                }
                if ($result_count) {
                    array_multisort($values, SORT_DESC, $result);
                    $result = ReindexResults($result);
                    $values = ReindexResults($values);
                    $last_value = 1;
                    $scale = 100 / $values[$last_value];
                    for ($i = $last_value; $i <= $result_count; $i++) {
                        $result[$i]['RELEVANCE'] = '<!--' . (int) ($values[$i] * $scale) . '--><IMG SRC="assets/pixel_grey.gif" width=' . (int) ($values[$i] * $scale) . ' height=10>';
                    }
                }
                //$column_names['RELEVANCE'] = 'Relevance';
                if (is_array($group) && count($group)) {
                    $options['count'] == false;
                    $display_zero = true;
                }
            }
            // END SEARCHES ---
            if ($_REQUEST['LO_sort']) {
                foreach ($result as $sort) {
                    if (substr($sort[$_REQUEST['LO_sort']], 0, 4) != '<!--') {
                        $sort_array[] = $sort[$_REQUEST['LO_sort']];
                    } else {
                        $sort_array[] = substr($sort[$_REQUEST['LO_sort']], 4, strpos($sort[$_REQUEST['LO_sort']], '-->') - 5);
                    }
                }
                if ($_REQUEST['LO_direction'] == -1) {
                    $dir = SORT_DESC;
                } else {
                    $dir = SORT_ASC;
                }
                if ($result_count > 1) {
                    if (is_int($sort_array[1]) || is_double($sort_array[1])) {
                        array_multisort($sort_array, $dir, SORT_NUMERIC, $result);
                    } elseif (VerifyDate_sort($sort_array[1])) {
                        array_multisort(date_to_timestamp($sort_array), $dir, SORT_NUMERIC, $result);
                    } elseif ($_REQUEST['LO_sort'] == 'POINTS') {
                        array_multisort(point_to_number($sort_array), $dir, SORT_NUMERIC, $result);
                    } elseif ($_REQUEST['LO_sort'] == 'PERCENT' || $_REQUEST['LO_sort'] == 'LETTER_GRADE' || $_REQUEST['LO_sort'] == 'GRADE_PERCENT') {
                        array_multisort(percent_to_number($sort_array), $dir, SORT_NUMERIC, $result);
                    } elseif ($_REQUEST['LO_sort'] == 'BAR1') {
                        array_multisort(range_to_number($sort_array), $dir, SORT_NUMERIC, $result);
                    } elseif ($_REQUEST['LO_sort'] == 'BAR2') {
                        array_multisort(rank_to_number($sort_array), $dir, SORT_NUMERIC, $result);
                    } else {
                        array_multisort($sort_array, $dir, $result);
                    }
                    for ($i = $result_count - 1; $i >= 0; $i--) {
                        $result[$i + 1] = $result[$i];
                    }
                    unset($result[0]);
                }
            }
        }
        // HANDLE SAVING THE LIST ---
        if ($_REQUEST['LO_save'] == '1') {
            if (!$options['save_delimiter'] && Preferences('DELIMITER') == 'CSV') {
                $options['save_delimiter'] = 'comma';
            }
            switch ($options['save_delimiter']) {
                case 'comma':
                    $extension = 'csv';
                    break;
                case 'xml':
                    $extension = 'xml';
                    break;
                default:
                    $extension = 'xls';
                    break;
            }
            ob_end_clean();
            if ($options['save_delimiter'] != 'xml') {
                foreach ($column_names as $key => $value) {
                    $output .= str_replace('&nbsp;', ' ', eregi_replace('<BR>', ' ', ereg_replace('<!--.*-->', '', $value))) . ($options['save_delimiter'] == 'comma' ? ',' : "\t");
                }
                $output .= "\n";
            }
            foreach ($result as $item) {
                foreach ($column_names as $key => $value) {
                    if ($options['save_delimiter'] == 'comma' && !$options['save_quotes']) {
                        $item[$key] = str_replace(',', ';', $item[$key]);
                    }
                    $item[$key] = eregi_replace('<SELECT.*SELECTED\\>([^<]+)<.*</SELECT\\>', '\\1', $item[$key]);
                    $item[$key] = eregi_replace('<SELECT.*</SELECT\\>', '', $item[$key]);
                    $output .= ($options['save_quotes'] ? '"' : '') . ($options['save_delimiter'] == 'xml' ? '<' . str_replace(' ', '', $value) . '>' : '') . ereg_replace('<[^>]+>', '', ereg_replace("<div onclick='[^']+'>", '', ereg_replace(' +', ' ', ereg_replace('&[^;]+;', '', str_replace('<BR>&middot;', ' : ', str_replace('&nbsp;', ' ', $item[$key])))))) . ($options['save_delimiter'] == 'xml' ? '</' . str_replace(' ', '', $value) . '>' . "\n" : '') . ($options['save_quotes'] ? '"' : '') . ($options['save_delimiter'] == 'comma' ? ',' : "\t");
                }
                $output .= "\n";
            }
            header("Cache-Control: public");
            header("Pragma: ");
            header("Content-Type: application/{$extension}");
            header("Content-Disposition: inline; filename=\"" . ProgramTitle() . ".{$extension}\"\n");
            if ($options['save_eval']) {
                eval($options['save_eval']);
            }
            echo $output;
            exit;
        }
        // END SAVING THE LIST ---
        if ($options['center']) {
            #echo '<CENTER>';
            if ($result_count > $num_displayed || ($options['count'] || $display_zero) && (($result_count == 0 || $display_count == 0) && $plural || ($result_count == 0 || $display_count == 0))) {
                #echo "<TABLE border=0 cellspacing=3 cellpadding=6>" ;
                if (isset($_REQUEST['_openSIS_PDF'])) {
                    #echo " width=98%";
                    echo " <TR><TD align=center>";
                }
            }
        }
        if ($options['count'] || $display_zero) {
            if (($result_count == 0 || $display_count == 0) && $plural) {
                echo "<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>" . _('No') . " {$plural} " . _('were found.') . "</b></td></tr><tr><td colspan=2 class=clear></td></tr></table></div>";
            } elseif ($result_count == 0 || $display_count == 0) {
                echo '<div style=text-align:left><table cellpadding=5 cellspacing=5 class=alert_box ><tr><td class=alert></td><td class=alert_msg ><b>' . _('None were found.') . '</b></td></tr><tr><td colspan=2 class=clear></td></tr></table></div>';
            }
        }
        if ($result_count != 0 || $_REQUEST['LO_search'] && $_REQUEST['LO_search'] != 'Search') {
            if (!isset($_REQUEST['_openSIS_PDF'])) {
                if (!$Request_page) {
                    $Request_page = 1;
                }
                if (!$_REQUEST['LO_direction']) {
                    $_REQUEST['LO_direction'] = 1;
                }
                $start = ($Request_page - 1) * $num_displayed + 1;
                $stop = $start + ($num_displayed - 1);
                if ($stop > $result_count) {
                    $stop = $result_count;
                }
                if ($result_count > $num_displayed) {
                    echo $where_message = "<strong><br>\n\t\t\t\t\t\t\t\t\t    {$start} through {$stop}</strong>";
                    echo "<div style=text-align:right;margin-top:-14px;padding-right:15px><strong>" . _('Go to Page') . " ";
                    if (ceil($result_count / $num_displayed) <= 10) {
                        for ($i = 1; $i <= ceil($result_count / $num_displayed); $i++) {
                            if ($i != $Request_page) {
                                if ($for_window == 'for_window') {
                                    $pages .= "<A HREF=" . str_replace('Modules.php', 'for_window.php', $PHP_tmp_SELF) . "&LO_sort={$_REQUEST['LO_sort']}&LO_direction={$_REQUEST['LO_direction']}&LO_search=" . urlencode($_REQUEST['LO_search']) . "&page={$i}&list_type={$singular}>{$i}</A>, ";
                                } else {
                                    $pages .= "<A HREF={$PHP_tmp_SELF}&LO_sort={$_REQUEST['LO_sort']}&LO_direction={$_REQUEST['LO_direction']}&LO_search=" . urlencode($_REQUEST['LO_search']) . "&page={$i}&list_type={$singular}>{$i}</A>, ";
                                }
                            } else {
                                $pages .= "{$i}, ";
                            }
                        }
                        $pages = substr($pages, 0, -2);
                    } else {
                        for ($i = 1; $i <= 7; $i++) {
                            if ($i != $Request_page) {
                                $pages .= "<A HREF={$PHP_tmp_SELF}&LO_sort={$_REQUEST['LO_sort']}&LO_direction={$_REQUEST['LO_direction']}&LO_search=" . urlencode($_REQUEST['LO_search']) . "&page={$i}>{$i}</A>, ";
                            } else {
                                $pages .= "{$i}, ";
                            }
                        }
                        $pages = substr($pages, 0, -2) . " ... ";
                        for ($i = ceil($result_count / $num_displayed) - 2; $i <= ceil($result_count / $num_displayed); $i++) {
                            if ($i != $Request_page) {
                                $pages .= "<A HREF={$PHP_tmp_SELF}&LO_sort={$_REQUEST['LO_sort']}&LO_direction={$_REQUEST['LO_direction']}&LO_search=" . urlencode($_REQUEST['LO_search']) . "&page={$i}>{$i}</A>, ";
                            } else {
                                $pages .= "{$i}, ";
                            }
                        }
                        $pages = substr($pages, 0, -2) . " &nbsp;<A HREF={$PHP_tmp_SELF}&LO_sort={$_REQUEST['LO_sort']}&LO_direction={$_REQUEST['LO_direction']}&LO_search=" . urlencode($_REQUEST['LO_search']) . "&page=" . ($Request_page + 1) . ">" . _('Next Page') . "</A><BR>";
                    }
                    echo $pages;
                    //echo '</td></tr></table></div>';
                    echo '</strong></div>';
                    //echo '<BR>';
                }
            } else {
                $start = 1;
                $stop = $result_count;
                if ($cols > 8 || $_REQUEST['expanded_view']) {
                    $_SESSION['orientation'] = 'landscape';
                    $repeat_headers = 16;
                } else {
                    $repeat_headers = 27;
                }
                if ($options['print']) {
                    $html = explode('<!-- new page -->', strtolower(ob_get_contents()));
                    $html = $html[count($html) - 1];
                    echo '</TD></TR></TABLE>';
                    $br = substr_count($html, '<br>') + substr_count($html, '</p>') + substr_count($html, '</tr>') + substr_count($html, '</h1>') + substr_count($html, '</h2>') + substr_count($html, '</h3>') + substr_count($html, '</h4>') + substr_count($html, '</h5>');
                    if ($br % 2 != 0) {
                        $br++;
                        echo '<BR>';
                    }
                } else {
                    echo '</TD></TR></TABLE>';
                }
            }
            // END MISC ---
            // WIDTH = 100%
            echo '<TABLE width=98% border=0 cellspacing=0 cellpadding=0><TR>';
            // SEARCH BOX & MORE HEADERS
            if ($where_message || $singular && $plural || !isset($_REQUEST['_openSIS_PDF']) && $options['search']) {
                echo '<TD align=center>';
                echo '<TABLE cellpadding=1 width=100% border=0 class=\\"grid\\">';
                echo "<TR><TD align=left valign=middle>";
                if ($singular && $plural && $options['count']) {
                    if ($display_count > 1) {
                        echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>{$display_count} {$plural} " . _('were found.') . "</b></td></tr></table>";
                    } elseif ($display_count == 1) {
                        echo "<table cellpadding=5 cellspacing=5 class=alert_box align=left ><tr><td class=notice></td><td class=notice_msg ><b>" . _('1') . " {$singular} " . _('was found.') . "</b></td></tr></table>";
                    }
                    #if($where_message)
                    #	echo '<br>'.$where_message;
                }
                if ($options['save'] && !isset($_REQUEST['_openSIS_PDF']) && $result_count > 0) {
                    //echo str_replace("Modules.php", "for_export.php", $PHP_tmp_SELF);
                    echo "<table cellpadding=0 cellspacing=0 class=download align=left ><tr><td><A HREF=" . str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF) . "&{$extra}&LO_save=1&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0 alt=\"Download\" title=\"Download\"></a></td></tr></table>";
                }
                //echo "<br><br><table class=download ><tr><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true ><IMG SRC=assets/download.png border=0></a></td><td><A HREF=".str_replace('Modules.php', 'for_export.php', $PHP_tmp_SELF)."&$extra&_openSIS_PDF=true >Download</A></td></tr></table>";
                echo '</TD>';
                $colspan = 1;
                if (!isset($_REQUEST['_openSIS_PDF']) && $options['search']) {
                    $_REQUEST['portal_search'] = 'true';
                    $tmp_REQUEST = $_REQUEST;
                    unset($tmp_REQUEST['LO_search']);
                    unset($tmp_REQUEST['page']);
                    echo '<TD height="50" align=right valign=middle style="white-space:nowrap;">&nbsp;&nbsp;';
                    echo "<INPUT type=hidden id=hidden_field ><INPUT type=text class='cell_medium'  id=LO_search name=LO_search value='" . ($_REQUEST['LO_search'] && $_REQUEST['LO_search'] != 'Search' ? $_REQUEST['LO_search'] : 'Search\' style=\'color:BBBBBB\''), "' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onKeyUp='fill_hidden_field(\"hidden_field\",this.value)' onkeypress='if(event.keyCode==13){document.location.href=\"" . PreparePHP_SELF($tmp_REQUEST) . "&LO_search=\"+document.getElementById(\"hidden_field\").value; return false;} '>&nbsp;&nbsp;<INPUT type=button class='btn_go' value=" . _('Go') . " onclick='document.location.href=\"" . PreparePHP_SELF($tmp_REQUEST) . "&LO_search=\"+document.getElementById(\"hidden_field\").value;'></TD>";
                    $colspan++;
                }
                echo "</TR>";
                echo '<TR style="height:0;"><TD width=100% align=center colspan=' . $colspan . '><DIV id=LOx' . (count($column_names) + ($result_count != 0 && $cols && !isset($_REQUEST['_openSIS_PDF']) ? 1 : 0) + ($remove && !isset($_REQUEST['_openSIS_PDF']) ? 1 : 0)) . ' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
            } else {
                echo '<TD width=100% align=right><DIV id=LOx' . (count($column_names) + ($result_count != 0 && $cols && !isset($_REQUEST['_openSIS_PDF']) ? 1 : 0) + ($remove && !isset($_REQUEST['_openSIS_PDF']) ? 1 : 0)) . ' style="width:0; position: relative; height:0;"></DIV>';
            }
            // END SEARCH BOX ----
            echo '</TD></TR><TR><TD>';
            // SHADOW
            if (!isset($_REQUEST['_openSIS_PDF'])) {
                //echo "<link rel='stylesheet' type='text/css' href='styles/paging.css' />\n";
                echo '<div id="pagerNavPosition"></div>';
                echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
            }
            echo "<TABLE id='results' cellpadding=6 width=96% cellspacing=1 class=\"grid\" align=center>";
            if (!isset($_REQUEST['_openSIS_PDF']) && $stop - $start > 10) {
                echo '<THEAD>';
            }
            if (!isset($_REQUEST['_openSIS_PDF'])) {
                echo '<TR>';
            }
            $i = 1;
            if ($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count != 0) {
                //THIS LINE IS FOR COLUMN HEADING
                echo "<TD class=subtabs><DIV id=LOx{$i} style='position: relative;'></DIV></TD>";
                $i++;
            }
            if ($result_count != 0 && $cols && !isset($_REQUEST['_openSIS_PDF'])) {
                foreach ($column_names as $key => $value) {
                    if ($_REQUEST['LO_sort'] == $key) {
                        $direction = -1 * $_REQUEST['LO_direction'];
                    } else {
                        $direction = 1;
                    }
                    //THIS LINE IS FOR COLUMN HEADING
                    echo "<TD class=subtabs><DIV id=LOx{$i} style='position: relative;'></DIV>";
                    echo "<A ";
                    if ($options['sort']) {
                        if ($for_window == 'for_window') {
                            echo "HREF=#";
                        } else {
                            echo "HREF={$PHP_tmp_SELF}&page={$_REQUEST['page']}&LO_sort={$key}&LO_direction={$direction}&LO_search=" . urlencode($_REQUEST['LO_search']);
                        }
                    }
                    echo " class=column_heading><b>{$value}</b></A>";
                    if ($i == 1) {
                        echo "<DIV id=LOy0 style='position: relative;'></DIV>";
                    }
                    echo "</TD>";
                    $i++;
                }
                //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
                echo "</TR>";
            }
            $color = 'class=even';
            //style="height: 300px; overflow: auto; padding-right: 16px;"
            if (!isset($_REQUEST['_openSIS_PDF']) && $stop - $start > 10) {
                echo '</THEAD><TBODY>';
            }
            // mab - enable add link as first or last
            if ($result_count != 0 && $link['add']['first'] && $stop - $start >= $link['add']['first']) {
                //if($remove && !isset($_REQUEST['_openSIS_PDF']))
                //	$cols++;
                if ($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF'])) {
                    echo "<TR><TD colspan=" . ($remove ? $cols + 1 : $cols) . " align=left class=even>" . button('add', $link['add']['title'], $link['add']['link']) . "</TD></TR>";
                } elseif ($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF'])) {
                    echo "<TR><TD colspan=" . ($remove ? $cols + 1 : $cols) . " align=left class=even>" . button('add') . $link['add']['span'] . "</TD></TR>";
                } elseif ($link['add']['html'] && $cols) {
                    echo "<TR {$color}>";
                    if ($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove']) {
                        echo "<TD class=even align=left>" . $link['add']['html']['remove'] . "</TD>";
                    } elseif ($remove && !isset($_REQUEST['_openSIS_PDF'])) {
                        echo "<TD class=even align=left>" . button('add') . "</TD>";
                    }
                    foreach ($column_names as $key => $value) {
                        echo "<TD class=even align=left >" . $link['add']['html'][$key] . "</TD>";
                    }
                    echo "</TR>";
                    $count++;
                }
            }
            for ($i = $start; $i <= $stop; $i++) {
                $item = $result[$i];
                if (isset($_REQUEST['_openSIS_PDF']) && $options['print'] && count($item)) {
                    foreach ($item as $key => $value) {
                        $value = eregi_replace('<SELECT.*SELECTED\\>([^<]+)<.*</SELECT\\>', '\\1', $value);
                        $value = eregi_replace('<SELECT.*</SELECT\\>', '', $value);
                        if (strpos($value, 'LO_field') === false) {
                            $item[$key] = str_replace(' ', '&nbsp;', ereg_replace("<div onclick='[^']+'>", '', $value));
                        } else {
                            $item[$key] = ereg_replace("<div onclick='[^']+'>", '', $value);
                        }
                    }
                }
                if ($item['row_color']) {
                    $color = $item['row_color'];
                } elseif ($color == 'class=even') {
                    $color = $side_color;
                } else {
                    $color = 'class=even';
                }
                //$color = '#EDF3FE';
                if (isset($_REQUEST['_openSIS_PDF']) && $count % $repeat_headers == 0) {
                    if ($count != 0) {
                        echo '</TABLE><TABLE cellpadding=6 width=820 class=\\"grid\\">';
                        echo '<!-- NEW PAGE -->';
                    }
                    echo "<TR>";
                    if ($remove && !isset($_REQUEST['_openSIS_PDF'])) {
                        echo "<TD class=grid></TD>";
                    }
                    if ($cols) {
                        foreach ($column_names as $key => $value) {
                            echo "<TD class=grid >" . str_replace(' ', '&nbsp;', $value) . "</TD>";
                        }
                    }
                    echo "</TR>";
                }
                if ($count == 0) {
                    $count = $br;
                }
                echo "<TR {$color}>";
                $count++;
                if ($remove && !isset($_REQUEST['_openSIS_PDF'])) {
                    $button_title = $link['remove']['title'];
                    //if(!$button_title)
                    //$button_title = 'Remove';
                    $button_link = $link['remove']['link'];
                    if (count($link['remove']['variables'])) {
                        foreach ($link['remove']['variables'] as $var => $val) {
                            $button_link .= "&{$var}=" . $item[$val];
                        }
                    }
                    echo "<TD {$color}>" . button('remove', $button_title, $button_link) . "</TD>";
                }
                if ($cols) {
                    foreach ($column_names as $key => $value) {
                        if ($link[$key] && !isset($_REQUEST['_openSIS_PDF'])) {
                            echo "<TD {$color} >";
                            if ($key == 'FULL_NAME') {
                                echo '<DIV id=LOy' . ($count - $br) . ' style="height: 100%; min-height: 100%; position: relative;">';
                            }
                            if ($link[$key]['js'] === true) {
                                echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
                                if (count($link[$key]['variables'])) {
                                    foreach ($link[$key]['variables'] as $var => $val) {
                                        echo "&{$var}=" . urlencode($item[$val]);
                                    }
                                }
                                echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
                                if ($link[$key]['extra']) {
                                    echo ' ' . $link[$key]['extra'];
                                }
                                echo ">";
                            } else {
                                echo "<A HREF={$link[$key][link]}";
                                if (count($link[$key]['variables'])) {
                                    foreach ($link[$key]['variables'] as $var => $val) {
                                        echo "&{$var}=" . urlencode($item[$val]);
                                    }
                                }
                                if ($link[$key]['extra']) {
                                    echo ' ' . $link[$key]['extra'];
                                }
                                echo " onclick='grabA(this); return false;'>";
                            }
                            if ($color == Preferences('HIGHLIGHT')) {
                                echo '';
                            } else {
                                echo '<b>';
                            }
                            echo $item[$key];
                            echo '</b>';
                            if (!$item[$key]) {
                                echo '***';
                            }
                            echo "</A>";
                            if ($key == 'FULL_NAME') {
                                echo '</DIV>';
                            }
                            echo "</TD>";
                        } else {
                            echo "<TD {$color} >";
                            if ($key == 'FULL_NAME') {
                                echo '<DIV id=LOy' . ($count - $br) . '  style="position: relative;">';
                            }
                            if ($color == Preferences('HIGHLIGHT')) {
                                echo '';
                            }
                            echo $item[$key];
                            if (!$item[$key]) {
                                echo '&nbsp;';
                            }
                            if ($key == 'FULL_NAME') {
                                echo '<DIV>';
                            }
                            echo "</TD>";
                        }
                    }
                }
                echo "</TR>";
            }
            if ($result_count != 0 && (!$link['add']['first'] || $link['add']['first'] && $stop - $start < $link['add']['first'])) {
                //if($remove && !isset($_REQUEST['_openSIS_PDF']))
                //	$cols++;
                if ($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF'])) {
                    echo "<TR><TD colspan=" . ($remove ? $cols + 1 : $cols) . " align=left class=even>" . button('add', $link['add']['title'], $link['add']['link']) . "</TD></TR>";
                } elseif ($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF'])) {
                    echo "<TR><TD colspan=" . ($remove ? $cols + 1 : $cols) . " align=left class=even>" . button('add') . $link['add']['span'] . "</TD></TR>";
                } elseif ($link['add']['html'] && $cols) {
                    if ($count % 2) {
                        $color = 'class=even';
                    } else {
                        $color = $side_color;
                    }
                    echo "<TR {$color}>";
                    if ($remove && !isset($_REQUEST['_openSIS_PDF']) && $link['add']['html']['remove']) {
                        echo "<TD class=even align=left>" . $link['add']['html']['remove'] . "</TD>";
                    } elseif ($remove && !isset($_REQUEST['_openSIS_PDF'])) {
                        echo "<TD class=even align=left class=grid_button>" . button('add') . "</TD>";
                    }
                    foreach ($column_names as $key => $value) {
                        echo "<TD class=even align=left  valign=top>" . $link['add']['html'][$key] . "</TD>";
                    }
                    echo "</TR>";
                }
            }
            if ($result_count != 0) {
                if (!isset($_REQUEST['_openSIS_PDF']) && $stop - $start > 10) {
                    echo '</TBODY>';
                }
                echo "</TABLE>";
                // SHADOW
                if (!isset($_REQUEST['_openSIS_PDF'])) {
                    echo '</TD ></TR></TABLE>';
                    echo "<script language='javascript' type='text/javascript'>\n";
                    #echo "alert('calling pager');\n";
                    $number_rec = 100;
                    echo "var pager = new Pager('results',{$number_rec});\n";
                    echo "pager.init();\n";
                    echo "pager.showPageNav('pager', 'pagerNavPosition');\n";
                    echo "pager.showPage(1);\n";
                    echo "</script>\n";
                }
                echo "</TD ></TR>";
                echo "</TABLE>";
                if ($options['center']) {
                    echo '';
                }
            }
            // END PRINT THE LIST ---
        }
        if ($result_count == 0) {
            // mab - problem with table closing if not opened above - do same conditional?
            if ($result_count > $num_displayed || ($options['count'] || $display_zero) && (($result_count == 0 || $display_count == 0) && $plural || ($result_count == 0 || $display_count == 0))) {
                #echo '<td>'; //edited for Search in parents (user>> associate student with parents)
                if ($link['add']['link'] && !isset($_REQUEST['_openSIS_PDF'])) {
                    echo '<table width=120px cellspacing=8 cellpadding=6 ><tr><TD align=left class=lone_add >' . button('add', $link['add']['title'], $link['add']['link']) . '</td></tr></table>';
                } elseif (($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_openSIS_PDF'])) {
                    $color = $side_color;
                    if ($options['center']) {
                        #echo '<CENTER>';
                        // WIDTH=100%
                        //echo "<TABLE cellpadding=1 bgcolor=#f8f8f9 width=100%><TR><TD>";
                        // SHADOW
                        echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD align=center>';
                    }
                    if ($link['add']['html']) {
                        /*Here also change the colour for left corner*/
                        echo "<TABLE cellpadding=6 cellspacing=1 width=96% class=\"grid\"><TR><TD class=subtabs></TD>";
                        foreach ($column_names as $key => $value) {
                            //Here to change the ListOutput Header Colour
                            echo "<TD class=subtabs><A><b>" . $value . "</b></A></TD>";
                        }
                        echo "</TR>";
                        echo "<TR class=odd>";
                        if ($link['add']['html']['remove']) {
                            echo "<TD >" . $link['add']['html']['remove'] . "</TD>";
                        } else {
                            echo "<TD>" . button('add') . "</TD>";
                        }
                        foreach ($column_names as $key => $value) {
                            echo "<TD >" . $link['add']['html'][$key] . "</TD>";
                        }
                        echo "</TR>";
                        echo "</TABLE>";
                    } elseif ($link['add']['span'] && !isset($_REQUEST['_openSIS_PDF'])) {
                        echo "<TABLE><TR><TD align=center>" . button('add') . $link['add']['span'] . "</TD></TR></TABLE>";
                    }
                    // SHADOW
                    //echo '</TD></TR></TABLE>';
                    echo "</TD></TR></TABLE>";
                    if ($options['center']) {
                        echo '</CENTER>';
                    }
                }
            }
        }
        if ($result_count != 0) {
            if ($options['yscroll']) {
                echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
                echo '<TABLE cellpadding=6 id=LOy_table>';
                $i = 1;
                if ($cols && !isset($_REQUEST['_openSIS_PDF'])) {
                    $color = $side_color;
                    foreach ($result as $item) {
                        echo "<TR><TD {$color}  id=LO_row{$i}>";
                        if ($color == Preferences('HIGHLIGHT')) {
                            echo '';
                        }
                        echo $item['FULL_NAME'];
                        if (!$item['FULL_NAME']) {
                            echo '&nbsp;';
                        }
                        if ($color == Preferences('HIGHLIGHT')) {
                            echo '';
                        }
                        echo "</TD></TR>";
                        $i++;
                        if ($item['row_color']) {
                            $color = $item['row_color'];
                        } elseif ($color == 'class=even') {
                            $color = $side_color;
                        } else {
                            $color = 'class=even';
                        }
                    }
                }
                echo '</TABLE>';
                echo '</div>';
            }
            echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
            echo '<TABLE cellpadding=6 id=LOx_table><TR>';
            $i = 1;
            if ($remove && !isset($_REQUEST['_openSIS_PDF']) && $result_count != 0) {
                echo "<TD class=grid id=LO_col{$i}></TD>";
                $i++;
            }
            if ($cols && !isset($_REQUEST['_openSIS_PDF'])) {
                foreach ($column_names as $key => $value) {
                    echo '<TD class=grid id=LO_col' . $i . '><A class=column_heading><b>' . str_replace('controller', '', $value) . '</b></A></TD>';
                    $i++;
                }
            }
            echo '</TR></TABLE>';
            echo '</div>';
        }
    }
}
Ejemplo n.º 6
0
function refund_search_gateway($db, $refund_search_category, $refund_search_term)
{
    // global $smarty;
    $langvals = gateway_xml2php('refund');
    switch ($refund_search_category) {
        case "DATE":
            $refund_gateway_search_term = date_to_timestamp($db, $refund_search_term);
            return $refund_gateway_search_term;
            break;
        case "TYPE":
            switch ($refund_search_term) {
                case $langvals['refund_type_1']:
                    $refund_gateway_search_term = "1";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_type_2']:
                    $refund_gateway_search_term = "2";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_type_3']:
                    $refund_gateway_search_term = "3";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_type_4']:
                    $refund_gateway_search_term = "4";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_type_5']:
                    $refund_gateway_search_term = "5";
                    return $refund_gateway_search_term;
                    break;
                default:
                    $refund_search_gateway = $refund_search_term;
                    return $refund_search_gateway;
                    break;
            }
        case "PAYMENT_METHOD":
            switch ($refund_search_term) {
                case $langvals['refund_payment_method_1']:
                    $refund_gateway_search_term = "1";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_2']:
                    $refund_gateway_search_term = "2";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_3']:
                    $refund_gateway_search_term = "3";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_4']:
                    $refund_gateway_search_term = "4";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_5']:
                    $refund_gateway_search_term = "5";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_6']:
                    $refund_gateway_search_term = "6";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_7']:
                    $refund_gateway_search_term = "7";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_8']:
                    $refund_gateway_search_term = "8";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_9']:
                    $refund_gateway_search_term = "9";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_10']:
                    $refund_gateway_search_term = "10";
                    return $refund_gateway_search_term;
                    break;
                case $langvals['refund_payment_method_11']:
                    $refund_gateway_search_term = "11";
                    return $refund_gateway_search_term;
                    break;
            }
        default:
            $refund_gateway_search_term = "%" . $refund_search_term . "%";
            return $refund_gateway_search_term;
            break;
    }
}
 function testDeveloping_preview()
 {
     global $t, $bx, $auth;
     global $cost, $license, $cooperation, $valid_day, $valid_month, $valid_year, $start_day, $start_month, $start_year, $duration;
     $proid = 'this is the proid';
     $cost = 'ths is the cost';
     $license = 'thsi is the license';
     $cooperation = 'this is the coopeartion';
     $valid_day = 'this is the valid_day';
     $valid_month = 'thsi si the valid month';
     $valid_year = 'this is the valid year';
     $start_day = 'this is the start day';
     $start_month = 'this is the start month';
     $start_year = 'this is the start year';
     $duration = 'this is the duration';
     $slen = strlen(timestr(time())) + 1188;
     $bx = $this->_create_default_box();
     $this->capture_call('developing_preview', $slen, array($proid));
     $this->_checkFor_a_box('PREVIEW', '<center><b>%s</b></center>');
     $this->_checkFor_a_box('Developing Proposal');
     $v = array('Cost' => $cost . " euros", 'License' => $license, 'Cooperation' => $cooperation, 'Status' => 'Proposed', 'Validity' => timestr_middle(mktimestamp(date_to_timestamp($valid_day, $valid_month, $valid_year))), 'Start possible' => timestr_middle(mktimestamp(date_to_timestamp($start_day, $start_month, $start_year))), 'Duration' => $duration . " weeks");
     while (list($key, $val) = each($v)) {
         $str = sprintf('<b>%s:</b> %s\\n', $t->translate($key), $val);
         $this->_testFor_pattern('[<]..?[>]' . $this->_to_regexp($str));
     }
 }
Ejemplo n.º 8
0
function date_to_mysqldatetime($date = "", $datetime = TRUE)
{
    return timestamp_to_mysqldatetime(date_to_timestamp($date), $datetime);
}
Ejemplo n.º 9
0
}
log_event('Importing user information …');
$users_result = mysql_query('SELECT * FROM `' . $rashusers . '`') or die('Error retrieving user information: ' . mysql_error());
$count_users = 0;
while ($row = mysql_fetch_array($users_result)) {
    $count_users++;
    mysql_query('INSERT INTO `' . $chirpy_table_prefix . 'accounts`' . ' (`username`, `password`, `level`)' . ' VALUES ("' . $row['user'] . '", "' . $row['password'] . '", ' . convert_level($row['level']) . ')') or die('Error importing user information: ' . mysql_error());
}
log_event('Users imported: ' . $count_users, true);
mysqL_free_result($users_result);
log_event('Importing news items …');
$news_result = mysql_query('SELECT * FROM `' . $newstable . '`') or die('Error retrieving news: ' . mysql_error());
$count_news = 0;
while ($row = mysql_fetch_array($news_result)) {
    $count_news++;
    $date = date_to_timestamp($row['date']);
    if ($date <= 0) {
        die('Unable to convert ‘' + $row['date'] + '’ into a UNIX timestamp');
    }
    mysql_query('INSERT INTO `' . $chirpy_table_prefix . 'news`' . ' (`body`, `date`)' . ' VALUES ("' . addslashes(decode_html($row['news'])) . '", FROM_UNIXTIME(' . $date . '))') or die('Error importing news item: ' . mysql_error());
}
log_event('News items imported: ' . $count_news, true);
mysqL_free_result($news_result);
log_event('Importing quotes …');
$quotes_result = mysql_query('SELECT * FROM `' . $quotetable . '`') or die('Error retrieving quotes: ' . mysql_error());
$count_quotes = 0;
while ($row = mysql_fetch_array($quotes_result)) {
    $count_quotes++;
    $rating = $row['rating'];
    // We use abs($rating) as the number of votes here, since RQMS doesn't
    // seem to keep it anywhere.
Ejemplo n.º 10
0
<?php

require_once 'include.php';
if (!xml2php('stats')) {
    $smarty->assign('error_msg', "Error in language file");
}
if (isset($VAR['submit'])) {
    // General Section
    /* Change dates to proper timestamps */
    $start_date = date_to_timestamp($db, $VAR['start_date']);
    $smarty->assign('start_date', $start_date);
    $end_date = date_to_timestamp($db, $VAR['end_date']);
    $smarty->assign('end_date', $end_date);
    /* Count open work orders in selected period */
    $q = "SELECT count(*) AS count FROM " . PRFX . "TABLE_WORK_ORDER WHERE WORK_ORDER_OPEN_DATE  >= '{$start_date}' AND WORK_ORDER_OPEN_DATE  <= '{$end_date}'";
    if (!($rs = $db->Execute($q))) {
        echo 'Error: ' . $db->ErrorMsg();
        die;
    }
    $wo_opened = $rs->fields['count'];
    $smarty->assign('wo_opened', $wo_opened);
    /* Count closed work orders in selected period */
    $q = "SELECT count(*) AS count FROM " . PRFX . "TABLE_WORK_ORDER WHERE WORK_ORDER_CLOSE_DATE  >= '{$start_date}' AND WORK_ORDER_CLOSE_DATE  <= '{$end_date}'";
    if (!($rs = $db->Execute($q))) {
        echo 'Error: ' . $db->ErrorMsg();
        die;
    }
    $wo_closed = $rs->fields['count'];
    $smarty->assign('wo_closed', $wo_closed);
    /* Count New Customers in selected period */
    $q = "SELECT count(*) AS count FROM " . PRFX . "TABLE_CUSTOMER WHERE CREATE_DATE  >= '{$start_date}' AND CREATE_DATE  <= '{$end_date}'";
Ejemplo n.º 11
0
function update_supplier($db, $VAR)
{
    $checked_date = date_to_timestamp($db, $VAR['supplierDate']);
    //Remove Extra Slashes caused by Magic Quotes
    $supplierAddress_string = $VAR['supplierAddress'];
    $supplierAddress_string = stripslashes($supplierAddress_string);
    $supplierNotes_string = $VAR['supplierNotes'];
    $supplierNotes_string = stripslashes($supplierNotes_string);
    $supplierDescription_string = $VAR['supplierDescription'];
    $supplierDescription_string = stripslashes($supplierDescription_string);
    $sql = "UPDATE " . PRFX . "TABLE_SUPPLIER SET\n\n\t\t\tSUPPLIER_NAME\t\t\t= " . $db->qstr($VAR['supplierName']) . ",\n\t\t\tSUPPLIER_CONTACT\t\t= " . $db->qstr($VAR['supplierContact']) . ",\n\t\t\tSUPPLIER_TYPE\t\t\t= " . $db->qstr($VAR['supplierType']) . ",\n\t\t\tSUPPLIER_PHONE                  = " . $db->qstr($VAR['supplierPhone']) . ",\n\t\t\tSUPPLIER_FAX                    = " . $db->qstr($VAR['supplierFax']) . ",\n                        SUPPLIER_MOBILE                 = " . $db->qstr($VAR['supplierMobile']) . ",\n                        SUPPLIER_WWW                    = " . $db->qstr($VAR['supplierWww']) . ",\n                        SUPPLIER_EMAIL                  = " . $db->qstr($VAR['supplierEmail']) . ",\n                        SUPPLIER_ADDRESS                = " . $db->qstr($supplierAddress_string) . ",\n                        SUPPLIER_CITY                   = " . $db->qstr($VAR['supplierCity']) . ",\n                        SUPPLIER_STATE                  = " . $db->qstr($VAR['supplierState']) . ",\n                        SUPPLIER_ZIP                    = " . $db->qstr($VAR['supplierZip']) . ",\n                        SUPPLIER_NOTES                  = " . $db->qstr($supplierNotes_string) . ",\n                        SUPPLIER_DESCRIPTION            = " . $db->qstr($supplierDescription_string) . "\n                        WHERE SUPPLIER_ID\t\t= " . $db->qstr($VAR['supplierID']);
    if (!($result = $db->Execute($sql))) {
        force_page('core', 'error&error_msg=MySQL Error: ' . $db->ErrorMsg() . '&menu=1&type=database');
        exit;
    } else {
        return true;
    }
}
Ejemplo n.º 12
0
function expense_search_gateway($db, $expense_search_category, $expense_search_term)
{
    // global $smarty;
    $langvals = gateway_xml2php('expense');
    switch ($expense_search_category) {
        case "DATE":
            $expense_gateway_search_term = date_to_timestamp($db, $expense_search_term);
            return $expense_gateway_search_term;
            break;
        case "TYPE":
            switch ($expense_search_term) {
                case $langvals['expense_type_1']:
                    $expense_gateway_search_term = "1";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_2']:
                    $expense_gateway_search_term = "2";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_3']:
                    $expense_gateway_search_term = "3";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_4']:
                    $expense_gateway_search_term = "4";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_5']:
                    $expense_gateway_search_term = "5";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_6']:
                    $expense_gateway_search_term = "6";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_7']:
                    $expense_gateway_search_term = "7";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_8']:
                    $expense_gateway_search_term = "8";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_9']:
                    $expense_gateway_search_term = "9";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_10']:
                    $expense_gateway_search_term = "10";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_11']:
                    $expense_gateway_search_term = "11";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_12']:
                    $expense_gateway_search_term = "12";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_13']:
                    $expense_gateway_search_term = "13";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_14']:
                    $expense_gateway_search_term = "14";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_15']:
                    $expense_gateway_search_term = "15";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_16']:
                    $expense_gateway_search_term = "16";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_17']:
                    $expense_gateway_search_term = "17";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_18']:
                    $expense_gateway_search_term = "18";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_19']:
                    $expense_gateway_search_term = "19";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_20']:
                    $expense_gateway_search_term = "20";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_type_21']:
                    $expense_gateway_search_term = "21";
                    return $expense_gateway_search_term;
                    break;
                default:
                    $expense_search_gateway = $expense_search_term;
                    return $expense_search_gateway;
                    break;
            }
        case "PAYMENT_METHOD":
            switch ($expense_search_term) {
                case $langvals['expense_payment_method_1']:
                    $expense_gateway_search_term = "1";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_2']:
                    $expense_gateway_search_term = "2";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_3']:
                    $expense_gateway_search_term = "3";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_4']:
                    $expense_gateway_search_term = "4";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_5']:
                    $expense_gateway_search_term = "5";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_6']:
                    $expense_gateway_search_term = "6";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_7']:
                    $expense_gateway_search_term = "7";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_8']:
                    $expense_gateway_search_term = "8";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_9']:
                    $expense_gateway_search_term = "9";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_10']:
                    $expense_gateway_search_term = "10";
                    return $expense_gateway_search_term;
                    break;
                case $langvals['expense_payment_method_11']:
                    $expense_gateway_search_term = "11";
                    return $expense_gateway_search_term;
                    break;
            }
        default:
            $expense_gateway_search_term = "%" . $expense_search_term . "%";
            return $expense_gateway_search_term;
            break;
    }
}
 function testSponsoring_insert()
 {
     global $db, $auth;
     $auth->set_uname("this is the username");
     $auth->set_perm("this is the permission");
     $db_config = new mock_db_configure(14);
     $db_q = array(0 => "SELECT COUNT(*) FROM sponsoring WHERE " . "proid='%s'", 1 => "INSERT sponsoring SET proid='%s',sponsor='%s'" . ",sponsoring_text='%s',budget='%s', status=" . "'%s', valid='%s',begin='%s',finish='%s'", 2 => "UPDATE configure SET sponsor='%s' WHERE " . "proid='%s'", 3 => "SELECT * FROM description WHERE proid='%s' " . "AND description_user='******'", 4 => "SELECT * FROM sponsoring,auth_user WHERE " . "proid='%s' AND sponsor=username ORDER BY " . "sponsoring.creation ASC", 5 => "SELECT * FROM sponsoring WHERE proid='%s' AND " . "sponsor='%s'", 6 => "UPDATE sponsoring SET sponsoring_text='%s', " . "budget='%s', status='%s', valid='%s'," . "begin='%s', finish='%s' " . "WHERE proid='%s' AND sponsor='%s'");
     $args = $this->_generate_records(array("proid", "user", "s_text", "budget", "v_day", "v_month", "v_year", "b_day", "b_month", "b_year", "f_day", "f_month", "f_year"), 4);
     $rows = $this->_generate_records(array("COUNT(*)"), 4);
     // first call
     $db_config->add_query(sprintf($db_q[0], $args[0]["proid"]), 0);
     $v = date_to_timestamp($args[0]["v_day"], $args[0]["v_month"], $args[0]["v_year"]);
     $b = date_to_timestamp($args[0]["b_day"], $args[0]["b_month"], $args[0]["b_year"]);
     $f = date_to_timestamp($args[0]["f_day"], $args[0]["f_month"], $args[0]["f_year"]);
     // query for checking the number of sponsoring the user has made
     $db_config->add_query(sprintf($db_q[5], $args[0]["proid"], $args[0]["user"]), 0);
     // insert query
     $db_config->add_query(sprintf($db_q[1], $args[0]["proid"], $args[0]["user"], $args[0]["s_text"], $args[0]["budget"], "P", $v, $b, $f), 0);
     // query for the show_sponsorings call
     $db_config->add_query(sprintf($db_q[4], $args[0]["proid"]), 0);
     // instance for the monitor_mail call
     $db_config->ignore_all_errors(1);
     // instance created by the is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[0]["proid"], $auth->auth["uname"]), 2);
     $rows[0]["COUNT(*)"] = 1;
     // status is 'P' (proposed)
     $db_config->add_record($rows[0], 0);
     // sponsoring_insert
     $db_config->add_record(false, 0);
     // show_sponsorings
     // two if statements
     $db_config->add_num_row(0, 0);
     $db_config->add_num_row(0, 0);
     $db_config->add_num_row(1, 0);
     // show_sponsorings
     $db_config->add_num_row(1, 2);
     // 2nd call to is_project_initiator
     // second call
     $db_config->add_query(sprintf($db_q[0], $args[1]["proid"]), 3);
     $v = date_to_timestamp($args[1]["v_day"], $args[1]["v_month"], $args[1]["v_year"]);
     $b = date_to_timestamp($args[1]["b_day"], $args[1]["b_month"], $args[1]["b_year"]);
     $f = date_to_timestamp($args[1]["f_day"], $args[1]["f_month"], $args[1]["f_year"]);
     // query for checking the number of sponsoring the user has made
     $db_config->add_query(sprintf($db_q[5], $args[1]["proid"], $args[1]["user"]), 3);
     $db_config->add_query(sprintf($db_q[1], $args[1]["proid"], $args[1]["user"], $args[1]["s_text"], $args[1]["budget"], "A", $v, $b, $f), 3);
     // this is the update query
     $db_config->add_query(sprintf($db_q[2], $auth->auth["uname"], $args[1]["proid"]), 3);
     // query for the show_sponsorings call
     $db_config->add_query(sprintf($db_q[4], $args[1]["proid"]), 3);
     // 1st call to is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[1]["proid"], $auth->auth["uname"]), 4);
     // instance for the monitor_mail call
     $db_config->ignore_all_errors(5);
     // instance created by the second call to is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[1]["proid"], $auth->auth["uname"]), 6);
     $rows[1]["COUNT(*)"] = 0;
     // status is 'A'
     $db_config->add_record($rows[1], 3);
     // sponsoring_insert
     $db_config->add_record(false, 3);
     // show_sponsorings
     $db_config->add_num_row(0, 3);
     // if ( $db->num_rows() == 1 ) {
     $db_config->add_num_row(0, 3);
     // if ( $db->num_rows() == 0 ) {
     $db_config->add_num_row(1, 3);
     // show_sponsorings
     $db_config->add_num_row(0, 4);
     // 1st call to is_project_initiator
     $db_config->add_num_row(0, 6);
     // 2nd call to is_project_initiator
     // third call, check that an update query is executed if the
     // user already has a sponsorship.
     $db_config->add_query(sprintf($db_q[0], $args[2]["proid"]), 7);
     $v = date_to_timestamp($args[2]["v_day"], $args[2]["v_month"], $args[2]["v_year"]);
     $b = date_to_timestamp($args[2]["b_day"], $args[2]["b_month"], $args[2]["b_year"]);
     $f = date_to_timestamp($args[2]["f_day"], $args[2]["f_month"], $args[2]["f_year"]);
     // query for checking the number of sponsoring the user has made
     $db_config->add_query(sprintf($db_q[5], $args[2]["proid"], $args[2]["user"]), 7);
     // update query because user has already contributed
     $args[2]["budget"] = 1;
     $db_config->add_query(sprintf($db_q[6], $args[2]["s_text"], $args[2]["budget"], "P", $v, $b, $f, $args[2]["proid"], $args[2]["user"]), 7);
     // query for the show_sponsorings call
     $db_config->add_query(sprintf($db_q[4], $args[2]["proid"]), 7);
     // instance for the monitor_mail call
     $db_config->ignore_all_errors(8);
     $db_config->ignore_all_errors(9);
     // instance created by the is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[2]["proid"], $auth->auth["uname"]), 10);
     $rows[2]["COUNT(*)"] = 1;
     // status is 'P' (proposed)
     $rows[2]["budget"] = 0;
     // old_budget should be less than new budget
     $db_config->add_record($rows[2], 7);
     // sponsoring_insert
     $db_config->add_record($rows[2], 7);
     // sponsoring_insert
     $db_config->add_record(false, 7);
     // show_sponsorings
     $db_config->add_num_row(1, 7);
     // user has already contributed
     $db_config->add_num_row(1, 7);
     // show_sponsorings
     $db_config->add_num_row(0, 10);
     // call to is_project_initiator
     // fourth call, this time the user has more than one sponsorship
     $db_config->add_query(sprintf($db_q[0], $args[3]["proid"]), 11);
     $v = date_to_timestamp($args[3]["v_day"], $args[3]["v_month"], $args[3]["v_year"]);
     $b = date_to_timestamp($args[3]["b_day"], $args[3]["b_month"], $args[3]["b_year"]);
     $f = date_to_timestamp($args[3]["f_day"], $args[3]["f_month"], $args[3]["f_year"]);
     // query for checking the number of sponsoring the user has made
     $db_config->add_query(sprintf($db_q[5], $args[3]["proid"], $args[3]["user"]), 11);
     // query for the show_sponsorings call
     $db_config->add_query(sprintf($db_q[4], $args[3]["proid"]), 11);
     // instance for the monitor_mail call
     $db_config->ignore_all_errors(11);
     $db_config->ignore_all_errors(12);
     // instance created by the is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[3]["proid"], $auth->auth["uname"]), 13);
     $rows[3]["COUNT(*)"] = 1;
     // status is 'P' (proposed)
     $db_config->add_record($rows[3], 11);
     // sponsoring_insert
     $db_config->add_record(false, 11);
     // show_sponsorings
     $db_config->add_num_row(2, 11);
     // user has already contributed
     $db_config->add_num_row(2, 11);
     // user has already contributed
     $db_config->add_num_row(1, 11);
     // show_sponsorings
     $db_config->add_num_row(0, 13);
     // call to is_project_initiator
     // ********************************************************************
     // first call
     $db = new DB_SourceAgency();
     $this->set_msg('test 1');
     $this->capture_call('sponsoring_insert', 442, $args[0]);
     $this->_testFor_pattern("<a href=\"personal[.]php3[?]username="******"this[+]is[+]the[+]username\" class=" . "\"\">Personal Page<\\/a>");
     // second call, status = A and is not project initiator
     $db = new DB_SourceAgency();
     $this->set_msg('test 2');
     $this->capture_call('sponsoring_insert', 141, $args[1]);
     $this->_testFor_pattern("<p><b>Congratulations<\\/b>. You are the " . "first sponsor. You can <a href=\"" . "configure_edit.php3[?]proid=proid_1\" " . "class=\"\">configure this project<\\/a>");
     // third call: user has already contributed and wishes to make
     // a change to that contribution
     $db = new DB_SourceAgency();
     $this->set_msg('test 3');
     $this->capture_call('sponsoring_insert', 0, $args[2]);
     // fourth call: user has made too many contributions
     $db = new DB_SourceAgency();
     $this->set_msg('test 4');
     $this->capture_call('sponsoring_insert', 137, $args[3]);
     $this->_testFor_pattern("<p><b>Database Failure:<\\/b> it seems you " . "have more than one sponsorship! Please " . "advice the administrator and have the " . "database corrected.");
     // finally check that everything went smoothly with the DB
     $this->_check_db($db_config);
 }
Ejemplo n.º 14
0
                    <div class="col-md-10">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="field-box">
                                    <label>Start date:</label>
                                    <input id="start_date" name="start_date" class="form-control input-datepicker" type="text" data-date-minviewmode="months" data-date-viewmode="years" data-date-format="mm/yyyy" value="<?php 
echo timestamp_to_date(set_value('start_date', date_to_timestamp('01/2012')));
?>
">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="field-box">
                                    <label>End date:</label>
                                    <input id="end_date" name="end_date" class="form-control input-datepicker" type="text" data-date-minviewmode="months" data-date-viewmode="years" data-date-format="mm/yyyy" value="<?php 
echo timestamp_to_date(set_value('end_date', date_to_timestamp('01/2013')));
?>
">
                                    <p>Leave this field empty if you are still working here.</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <button type="submit" class="btn btn-default">Save</button>
                    </div>
                </div>
            <?php 
echo form_close();
Ejemplo n.º 15
0
    echo $category->title;
    ?>
</option>
                            <?php 
}
?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <?php 
echo form_label('Completed', 'completion_date', array('class' => 'col-md-2 control-label'));
?>
                    <div class="col-md-10">
                        <input id="completion_date" name="completion_date" class="form-control input-datepicker" type="text" data-date-minviewmode="months" data-date-viewmode="years" data-date-format="mm/yyyy" value="<?php 
echo timestamp_to_date(set_value('completion_date', date_to_timestamp('01/2012')));
?>
">
                    </div>
                </div>
                <div class="form-group">
                    <?php 
echo form_label('Published', 'published', array('class' => 'col-md-2 control-label'));
?>
                    <div class="col-md-10 ctrls">
                        <div class="slider-frame">
                            <span class="slider-button on" data-off-text="No" data-on-text="Yes">ON</span>
                            <?php 
echo form_hidden('published', set_value('published', 1));
?>
                        </div>