Ejemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param \SedpMis\BaseReport\GridQuery\BaseReportGridQuery $gridQuery
  * @param string $startDate
  * @param string $endDate
  * @param string|null $columnPresentation
  */
 public function __construct($gridQuery, $startDate = null, $endDate = null, $columnPresentation = null)
 {
     $this->gridQuery = $gridQuery;
     $this->gridQuery->setDatesFilter($startDate = sql_date($startDate), $endDate = sql_date($endDate));
     if ($columnPresentation) {
         $this->gridQuery = $this->gridQuery->columnedReportGridQuery($columnPresentation);
     }
     $this->query = $this->gridQuery->makeQuery();
     $this->filterDates($startDate, $endDate);
 }
Ejemplo n.º 2
0
 public function retriveDailyIssueReports()
 {
     $date = date("Y-m-d");
     $date_after = strtotime(" {$date} + 1 day");
     $date_before = strtotime(" {$date} - 1 day");
     $date_after = sql_date($date_after);
     $date_before = sql_date($date_before);
     $sql = "\tSELECT con_m . * , con_d . * , si. *, stk_mcin.* ,siu.*,\n\t \t\t \t\tGROUP_CONCAT(scd.stock_code, ' ' ) stock_code,\n\t \t\t  \t\tGROUP_CONCAT(spd.stock_part, ' ' ) stock_part\n\t \t\t  \t\t\t\n\t\t\t \t\t FROM consumptions_master con_m, consumption_details con_d, \n\t\t\t \t\t stock_item si, stock_machine stk_mcin,\n\t\t\t \t\t stock_item_units siu,stock_part_details spd ,\n\t\t\t \t\t stock_code_details scd\n\t\t\t \t\t \n\t\t\t \t\t WHERE con_m.cm_id = con_d.consumptions_master_id\n\t\t\t\t \t\t AND con_d.stock_item_id = si.stock_item_id  \n\t\t\t\t \t\t AND si.stock_machine_id=stk_mcin.m_id \n\t\t\t\t \t\t AND si.stock_item_unit_id=\tsiu.stock_item_unit_id\t\t \t\t \t \n\t\t\t\t \t\t AND (con_m.created_at between '{$date_before}' AND '{$date_after}')\n\t\t\t\t\t\t AND si.stock_part_m_id=spd.stock_part_m_id \n\t\t\t\t\t\t AND si.stock_code_m_id=scd.stock_code_m_id \n\t\t\t \t\t  \t\n\t\t\t \t\t GROUP BY si.stock_item_id";
     return parent::selectQuery($sql);
 }
Ejemplo n.º 3
0
/**
 * @return number of days (also counting the dates) the date period spans over
 */
function num_days($d1, $d2)
{
    $d1 = ts($d1);
    $d2 = ts($d2);
    $dt1 = new DateTime(sql_date($d1));
    $dt2 = new DateTime(sql_date($d2));
    $interval = $dt1->diff($dt2);
    $days = $interval->format('%a');
    //Total amount of days
    return $days + 1;
}
Ejemplo n.º 4
0
 static function getDatabaseVersions()
 {
     $dbs = array('GEOIP_COUNTRY_EDITION' => GEOIP_COUNTRY_EDITION, 'GEOIP_REGION_EDITION_REV0' => GEOIP_REGION_EDITION_REV0, 'GEOIP_CITY_EDITION_REV0' => GEOIP_CITY_EDITION_REV0, 'GEOIP_ORG_EDITION' => GEOIP_ORG_EDITION, 'GEOIP_ISP_EDITION' => GEOIP_ISP_EDITION, 'GEOIP_CITY_EDITION_REV1' => GEOIP_CITY_EDITION_REV1, 'GEOIP_REGION_EDITION_REV1' => GEOIP_REGION_EDITION_REV1, 'GEOIP_PROXY_EDITION' => GEOIP_PROXY_EDITION, 'GEOIP_ASNUM_EDITION' => GEOIP_ASNUM_EDITION, 'GEOIP_NETSPEED_EDITION' => GEOIP_NETSPEED_EDITION, 'GEOIP_DOMAIN_EDITION' => GEOIP_DOMAIN_EDITION);
     $res = array();
     foreach ($dbs as $name => $id) {
         if (!geoip_db_avail($id)) {
             continue;
         }
         $info = geoip_database_info($id);
         $x = explode(' ', $info);
         $res[] = array('name' => $name, 'file' => geoip_db_filename($id), 'date' => sql_date(ts($x[1])), 'version' => $x[0]);
     }
     return $res;
 }
Ejemplo n.º 5
0
 function render()
 {
     if (!$this->name) {
         throw new \Exception('must set a name');
     }
     $header = XhtmlHeader::getInstance();
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/calendar/assets/skins/sam/calendar.css');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/calendar/calendar-min.js');
     $locale = LocaleHandler::getInstance();
     $div_holder = 'yui_date_hold' . mt_rand();
     $res = 'YAHOO.namespace("example.calendar");' . 'YAHOO.example.calendar.init = function() {' . 'var inTxt = YAHOO.util.Dom.get("' . $this->name . '");' . ($this->selected_date ? 'inTxt.value  = "' . sql_date($this->selected_date) . '";' : '') . 'var cal = YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("' . $div_holder . '");' . ($this->selected_date ? 'cal.cfg.setProperty("selected", "' . js_date($this->selected_date) . '");' . 'cal.cfg.setProperty("pagedate", "' . date('n/Y', $this->selected_date) . '");' : '') . 'cal.cfg.setProperty("start_weekday",' . $this->start_weekday . ');' . 'cal.cfg.setProperty("MONTHS_SHORT",' . Json::encode($locale->handle->month_short, false) . ');' . 'cal.cfg.setProperty("MONTHS_LONG",' . Json::encode($locale->handle->month_long, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_1CHAR",' . Json::encode($locale->handle->weekday_1char, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_SHORT",' . Json::encode($locale->handle->weekday_short, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_MEDIUM",' . Json::encode($locale->handle->weekday_medium, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_LONG",' . Json::encode($locale->handle->weekday_long, false) . ');' . 'cal.selectEvent.subscribe(function() {' . 'var dates = this.getSelectedDates();' . 'var inDate = dates[0];' . 'inTxt.value = inDate.getFullYear() + "-" + (inDate.getMonth() + 1) + "-" + inDate.getDate();' . '}, cal, true);' . 'cal.render();' . '}' . "\n" . 'YAHOO.util.Event.onDOMReady(YAHOO.example.calendar.init);';
     return '<div id="' . $div_holder . '"></div>' . '<div style="clear:both"></div>' . xhtmlInput($this->name) . '<br/>' . js_embed($res);
 }
Ejemplo n.º 6
0
 public function test1()
 {
     $this->assertEquals(SsnSwedish::isValid('811218-9876'), true);
     // known correct
     $this->assertEquals(SsnSwedish::isValid('19811218-9876', SsnSwedish::MALE), true);
     // known to be a male ssn
     $this->assertEquals(SsnSwedish::isValid('19811218-9876'), true);
     $this->assertEquals(SsnSwedish::isValid('800222-2222'), false);
     // known fake
     $this->assertEquals(SsnSwedish::isValid('20811218-9876'), false);
     // BAD, in the future!
     $this->assertEquals(sql_date(SsnSwedish::getTimestamp('811218-9876')), '1981-12-18');
     $this->assertEquals(SsnSwedish::getGender('811218-9876'), 'M');
 }
Ejemplo n.º 7
0
 function render()
 {
     if (!$this->name) {
         throw new \Exception('name must be configured');
     }
     $header = XhtmlHeader::getInstance();
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/calendar/assets/skins/sam/calendar.css');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/calendar/calendar-min.js');
     $res = '(function()' . '{' . 'function IntervalCalendar(container, cfg)' . '{' . 'this._iState = 0;' . 'cfg = cfg || {};' . 'cfg.multi_select = true;' . 'IntervalCalendar.superclass.constructor.call(this, container, cfg);' . 'this.beforeSelectEvent.subscribe(this._intervalOnBeforeSelect, this, true);' . 'this.selectEvent.subscribe(this._intervalOnSelect, this, true);' . 'this.beforeDeselectEvent.subscribe(this._intervalOnBeforeDeselect, this, true);' . 'this.deselectEvent.subscribe(this._intervalOnDeselect, this, true);' . '}' . 'IntervalCalendar._DEFAULT_CONFIG = YAHOO.widget.CalendarGroup._DEFAULT_CONFIG;' . 'YAHOO.lang.extend(IntervalCalendar, YAHOO.widget.CalendarGroup,' . '{' . '_dateString : function(d) {' . 'var a = [];' . 'a[this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.MDY_MONTH_POSITION.key)-1] = (d.getMonth() + 1);' . 'a[this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.MDY_DAY_POSITION.key)-1] = d.getDate();' . 'a[this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.MDY_YEAR_POSITION.key)-1] = d.getFullYear();' . 'var s = this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.DATE_FIELD_DELIMITER.key);' . 'return a.join(s);' . '},' . '_dateIntervalString : function(l, u) {' . 'var s = this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.DATE_RANGE_DELIMITER.key);' . 'return (this._dateString(l) + s + this._dateString(u));' . '},' . 'getInterval : function() {' . 'var dates = this.getSelectedDates();' . 'if(dates.length > 0) {' . 'var l = dates[0];' . 'var u = dates[dates.length - 1];' . 'return [l, u];' . '} else {' . 'return [];' . '}' . '},' . 'setInterval : function(d1, d2) {' . 'var b = (d1 <= d2);' . 'var l = b ? d1 : d2;' . 'var u = b ? d2 : d1;' . 'this.cfg.setProperty("selected", this._dateIntervalString(l, u), false);' . 'this._iState = 2;' . '},' . 'resetInterval : function() {' . 'this.cfg.setProperty("selected", [], false);' . 'this._iState = 0;' . '},' . '_intervalOnBeforeSelect : function(t,a,o) {' . 'this._iState = (this._iState + 1) % 3;' . 'if(this._iState == 0) {' . 'this.deselectAll();' . 'this._iState++;' . '}' . '},' . '_intervalOnSelect : function(t,a,o) {' . 'var dates = this.getSelectedDates();' . 'if(dates.length > 1) {' . 'var l = dates[0];' . 'var u = dates[dates.length - 1];' . 'this.cfg.setProperty("selected", this._dateIntervalString(l, u), false);' . '}' . 'this.render();' . '},' . '_intervalOnBeforeDeselect : function(t,a,o) {' . 'if(this._iState != 0) {' . 'return false;' . '}' . '},' . '_intervalOnDeselect : function(t,a,o) {' . 'if(this._iState != 0) {' . 'this._iState = 0;' . 'this.deselectAll();' . 'var d = a[0];' . 'var date = YAHOO.widget.DateMath.getDate(d[0], d[1] - 1, d[2]);' . 'var page = this.getCalendarPage(date);' . 'if(page) {' . 'page.beforeSelectEvent.fire();' . 'this.cfg.setProperty("selected", this._dateString(date), false);' . 'page.selectEvent.fire([d]);' . '}' . 'return false;' . '}' . '}' . '});' . 'YAHOO.namespace("example.calendar");' . 'YAHOO.example.calendar.IntervalCalendar = IntervalCalendar;' . '})();';
     $locale = LocaleHandler::getInstance();
     $div_holder = 'yui_di_hold' . mt_rand();
     $res .= 'YAHOO.util.Event.onDOMReady(function()' . '{' . 'var inTxt  = YAHOO.util.Dom.get("' . $this->name . '_from");' . 'var outTxt = YAHOO.util.Dom.get("' . $this->name . '_to");' . 'var inDate, outDate, interval;' . ($this->select_from ? 'inTxt.value  = "' . sql_date($this->select_from) . '";' : '') . ($this->select_to ? 'outTxt.value = "' . sql_date($this->select_to) . '";' : '') . 'var myConfigs =' . '{' . 'pages:2,' . ($this->select_from && $this->select_to ? 'selected:"' . js_date($this->select_from) . '-' . js_date($this->select_to) . '",' . 'pagedate:"' . date('n/Y', $this->select_from) . '",' : '') . 'start_weekday:' . $this->start_weekday . ',' . 'MONTHS_SHORT:' . Json::encode($locale->handle->month_short, false) . ',' . 'MONTHS_LONG:' . Json::encode($locale->handle->month_long, false) . ',' . 'WEEKDAYS_1CHAR:' . Json::encode($locale->handle->weekday_1char, false) . ',' . 'WEEKDAYS_SHORT:' . Json::encode($locale->handle->weekday_short, false) . ',' . 'WEEKDAYS_MEDIUM:' . Json::encode($locale->handle->weekday_medium, false) . ',' . 'WEEKDAYS_LONG:' . Json::encode($locale->handle->weekday_long, false) . ',' . '};' . 'var cal = new YAHOO.example.calendar.IntervalCalendar("' . $div_holder . '",myConfigs);' . 'cal.selectEvent.subscribe(function()' . '{' . 'interval = this.getInterval();' . 'if (interval.length == 2) {' . 'inDate = interval[0];' . 'inTxt.value =  inDate.getFullYear() + "-" + (inDate.getMonth() + 1) + "-" + inDate.getDate();' . 'if (interval[0].getTime() != interval[1].getTime()) {' . 'outDate = interval[1];' . 'outTxt.value = outDate.getFullYear() + "-" + (outDate.getMonth() + 1) + "-" + outDate.getDate();' . '} else {' . 'outTxt.value = "";' . '}' . '}' . '}, cal, true);' . 'cal.render();' . '});';
     return '<div id="' . $div_holder . '"></div>' . '<div style="clear:both"></div>' . js_embed($res) . xhtmlInput($this->name . '_from') . ' - ' . xhtmlInput($this->name . '_to');
 }
Ejemplo n.º 8
0
 function render()
 {
     if (!$this->name) {
         throw new \Exception('must set a name');
     }
     $header = XhtmlHeader::getInstance();
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/fonts/fonts-min.css');
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/button/assets/skins/sam/button.css');
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/container/assets/skins/sam/container.css');
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/calendar/assets/skins/sam/calendar.css');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/dragdrop/dragdrop-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/element/element-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/button/button-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/container/container-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/calendar/calendar-min.js');
     $header->embedCss('#container .bd form {' . 'clear:left;' . '}' . '#container .bd {' . 'padding:0;' . '}' . '#container .hd {' . 'text-align:left;' . '}' . '#container .ft .button-group {' . 'text-align:center;' . '}' . '#container_c.yui-overlay-hidden table {' . '*display:none;' . '}' . '#cal {' . 'border:none;' . 'padding:1em;' . '}');
     $locale = LocaleHandler::getInstance();
     $button_name = 'yui_dp_show_' . mt_rand();
     $res = 'YAHOO.util.Event.onDOMReady(function(){' . 'var Event = YAHOO.util.Event,' . 'Dom = YAHOO.util.Dom,' . 'dialog,' . 'calendar;' . 'var showBtn = Dom.get("' . $button_name . '");' . 'Event.on(showBtn, "click", function() {' . 'if (!dialog) {' . 'Event.on(document, "click", function(e) {' . 'var el = Event.getTarget(e);' . 'var dialogEl = dialog.element;' . 'if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != showBtn && !Dom.isAncestor(showBtn, el)) {' . 'dialog.hide();' . '}' . '});' . 'function resetHandler() {' . 'var selDates = calendar.getSelectedDates();' . 'var resetDate;' . 'if (selDates.length > 0) {' . 'resetDate = selDates[0];' . '} else {' . 'resetDate = calendar.today;' . '}' . 'calendar.cfg.setProperty("pagedate", resetDate);' . 'calendar.render();' . '}' . 'function closeHandler() {' . 'dialog.hide();' . '}' . 'dialog = new YAHOO.widget.Dialog("container", {' . 'visible:false,' . 'context:["' . $button_name . '", "tl", "bl"],' . 'buttons:[ {text:"Reset", handler: resetHandler, isDefault:true}, {text:"Close", handler: closeHandler}],' . 'draggable:false,' . 'close:true' . '});' . 'dialog.setHeader("Pick A Date");' . 'dialog.setBody(\'<div id="cal"></div>\');' . 'dialog.render(document.body);' . 'dialog.showEvent.subscribe(function() {' . 'if (YAHOO.env.ua.ie) {' . 'dialog.fireEvent("changeContent");' . '}' . '});' . '}' . 'if (!calendar) {' . 'calendar = new YAHOO.widget.Calendar("cal", {' . 'iframe:false,' . 'hide_blank_weeks:true,' . ($this->selected_date ? 'selected:"' . js_date($this->selected_date) . '",' . 'pagedate:"' . date('n/Y', $this->selected_date) . '",' : '') . 'start_weekday:' . $this->start_weekday . ',' . 'MONTHS_SHORT:' . Json::encode($locale->handle->month_short, false) . ',' . 'MONTHS_LONG:' . Json::encode($locale->handle->month_long, false) . ',' . 'WEEKDAYS_1CHAR:' . Json::encode($locale->handle->weekday_1char, false) . ',' . 'WEEKDAYS_SHORT:' . Json::encode($locale->handle->weekday_short, false) . ',' . 'WEEKDAYS_MEDIUM:' . Json::encode($locale->handle->weekday_medium, false) . ',' . 'WEEKDAYS_LONG:' . Json::encode($locale->handle->weekday_long, false) . ',' . '});' . 'calendar.render();' . 'calendar.selectEvent.subscribe(function() {' . 'if (calendar.getSelectedDates().length > 0) {' . 'var selDate = calendar.getSelectedDates()[0];' . 'Dom.get("' . $this->name . '").value = selDate.getFullYear() + "-" + (selDate.getMonth() + 1) + "-" + selDate.getDate();' . '} else {' . 'Dom.get("' . $this->name . '").value = "";' . '}' . 'dialog.hide();' . '});' . 'calendar.renderEvent.subscribe(function() {' . 'dialog.fireEvent("changeContent");' . '});' . '}' . 'var seldate = calendar.getSelectedDates();' . 'if (seldate.length > 0) {' . 'calendar.cfg.setProperty("pagedate", seldate[0]);' . 'calendar.render();' . '}' . 'dialog.show();' . '});' . '});';
     return xhtmlInput($this->name, sql_date($this->selected_date), 8) . ' ' . '<button type="button" id="' . $button_name . '" title="Pick a date">' . '<img src="' . relurl('core_dev/gfx/icon_date-picker.png') . '" alt="Pick a date"/>' . '</button>' . js_embed($res);
 }
Ejemplo n.º 9
0
 public function test4()
 {
     // VERIFY fixed bug wont reappear: date "0000-00-00" got converted to "-0001-11-30"
     $this->assertEquals(sql_date('0000-00-00'), '0000-00-00');
 }
Ejemplo n.º 10
0
 /**
  * tvrage.com returns max 20 results
  *
  * @return list of matching show names & tvrage.com id:s
  */
 function searchShows($query)
 {
     if (!$query) {
         return false;
     }
     $temp = TempStore::getInstance();
     $key = 'TvRageClient/shows/' . $query;
     $res = $temp->get($key);
     if ($res) {
         return unserialize($res);
     }
     $url = 'http://services.tvrage.com/feeds/full_search.php?show=' . urlencode($query);
     $this->setUrl($url);
     if ($this->api_key) {
         $this->Url->setParam('key', $this->api_key);
     }
     $data = $this->getBody();
     $xml = simplexml_load_string($data);
     $res = array();
     foreach ($xml->show as $s) {
         $show = new TvShow();
         $show->id = strval($s->showid);
         $show->name = strval($s->name);
         $show->country = strval($s->country);
         $show->started = sql_date(self::parseDate(strval($s->started)));
         $show->ended = sql_date(self::parseDate(strval($s->ended)));
         $show->status = self::parseStatus($s->status, $show->started, $show->ended);
         $show->store();
         $res[] = $show;
     }
     $temp->set($key, serialize($res), '24h');
     return $res;
 }
Ejemplo n.º 11
0
 function setDate($date)
 {
     $this->date = ts(sql_date(ts($date)));
     ///XXX FIXME: helper function to round a timestamp to a datestamp
     $this->days_in_month = date('t', $this->date);
 }
Ejemplo n.º 12
0
function date_age($date)
{
    $date = sql_date($date);
    list($Y, $m, $d) = explode('-', $date);
    return date('md') < $m . $d ? date('Y') - $Y - 1 : date('Y') - $Y;
}
Ejemplo n.º 13
0
 public function render()
 {
     $res = sql_date($this->date) . ': ' . $this->get() . ' - ' . $this->title;
     return $res;
 }
Ejemplo n.º 14
0
if (is_duration('1a2d')) {
    echo "FAIL 32\n";
}
if (!is_duration(500)) {
    echo "FAIL 33\n";
}
if (sql_date(ts('2011-05-08')) != '2011-05-08') {
    echo "FAIL 40\n";
}
if (sql_date(ts('20110508')) != '2011-05-08') {
    echo "FAIL 41\n";
}
if (sql_date(ts('5/8/2011')) != '2011-05-08') {
    echo "FAIL 42\n";
}
if (sql_date(ts('05/08/2011')) != '2011-05-08') {
    echo "FAIL 43\n";
}
if (!is_hms('12:44:11.21')) {
    echo "FAIL 50\n";
}
if (!is_hms('00:00:00')) {
    echo "FAIL 51\n";
}
if (!is_hms('00:00:00.00')) {
    echo "FAIL 52\n";
}
if (is_hms('123.123.123')) {
    echo "FAIL 53\n";
}
if (!is_hms('12:44:11,21')) {