public static function config() { if (!empty(self::$config)) { return self::$config; } self::$config = Config::load('log'); return self::$config; }
function smarty_modifier_format_time($date) { if (is_string($date)) { $date = strtotime($date); } $f = Config::get("appearance", "time_format"); if (empty($f)) { $f = "H:i"; } return date($f, $date); }
function smarty_modifier_format_date($date) { if (empty($date) || $date == '0000-00-00 00:00:00' || $date == "0000-00-00") { return '-'; } if (is_string($date)) { $date = strtotime($date); } $f = Config::get("appearance", "date_format"); if (empty($f)) { $f = "d.m.Y"; } return date($f, $date); }
public static function send($module, $handler, $data = array()) { if (empty(static::$config)) { static::$config = Config::load('mail'); } Place::init(); static::clear(); $path = Module::path($module); if (empty($path)) { return; } $path .= '/emails/' . $handler; static::run($path, $data); return static::mail(); }
public function testJoin() { Config::initPath(__DIR__ . '/config'); $q = SQL::table('cody_product')->leftJoin('cody_product_variant', 'product_id', 'cody_product', 'product_id')->make(); $this->assertEquals("SELECT * FROM cody_product LEFT JOIN cody_product_variant ON cody_product_variant.product_id = cody_product.product_id", $q); $q = SQL::table('cody_pick_list_order')->leftJoin('cody_pick_list', array('pick_list_id' => array('cody_pick_list_order' => 'pick_list_id'), 'pick_list_type' => 'buyer'))->make(); $this->assertEquals("SELECT * FROM cody_pick_list_order LEFT JOIN cody_pick_list ON cody_pick_list.pick_list_id = cody_pick_list_order.pick_list_id AND cody_pick_list.pick_list_type ='buyer'", $q); $q = SQL::table('cody_product')->leftJoin(SQL::table('cody_product_variant')->on('product_id'))->make(); $this->assertEquals("SELECT * FROM cody_product LEFT JOIN cody_product_variant ON cody_product_variant.product_id = cody_product.product_id", $q); $q = SQL::table('cody_pick_list_order')->leftJoin(SQL::table('cody_pick_list')->on('pick_list_id')->onBy('pick_list_type', 'buyer'))->make(); $this->assertEquals("SELECT * FROM cody_pick_list_order LEFT JOIN cody_pick_list ON cody_pick_list.pick_list_id = cody_pick_list_order.pick_list_id AND cody_pick_list.pick_list_type = 'buyer'", $q); $q = SQL::table('cody_pick_list_order')->alias('plo')->leftJoin(SQL::table('cody_pick_list')->alias('pl')->whereBy('pick_list_id', 5)->on('pick_list_id')->onBy('pick_list_type', 'buyer'))->make(); $this->assertEquals("SELECT * FROM cody_pick_list_order plo LEFT JOIN cody_pick_list pl ON pl.pick_list_id = plo.pick_list_id AND pl.pick_list_type = 'buyer' WHERE (pl.pick_list_id = '5')", $q); $q = SQL::table('cody_category')->select("category_id, category_title")->leftJoin(SQL::table('cody_category_parent')->alias('t2')->on('category_id')->select('category_parent_id')->leftJoin(SQL::table('cody_category')->alias('t3')->on('category_id', 'category_parent_id')->select('category_title AS category_parent_title')))->orderBy('t2.category_id, t2.category_parent_length DESC')->make(); $this->assertEquals("SELECT category_id, category_title, category_parent_id, category_title AS category_parent_title" . " FROM cody_category" . " LEFT JOIN cody_category_parent t2 ON t2.category_id = cody_category.category_id" . " LEFT JOIN cody_category t3 ON t3.category_id = t2.category_parent_id" . " ORDER BY t2.category_id, t2.category_parent_length DESC", $q); $pickListProductIds = array(1, 2, 3); $q = SQL::table('cody_product_variant')->innerJoin(SQL::subquery(SQL::table('cody_pick_list_product')->whereBy('pick_list_product_id', $pickListProductIds)->whereNotBy('pick_list_product_amount_status', 'decreased')->groupBy('product_variant_id'))->alias('plp')->on('product_variant_id'))->innerJoin(SQL::table('cody_pick_list_product')->select('cody_pick_list_product.pick_list_product_id')->on('product_variant_id')->onBy('pick_list_product_id', $pickListProductIds)->onNotBy('pick_list_product_amount_status', 'decreased')->leftJoin(SQL::table('cody_order_product')->on('order_product_id')))->make(); $this->assertEquals("SELECT cody_pick_list_product.pick_list_product_id FROM cody_product_variant" . " INNER JOIN (" . "SELECT * FROM cody_pick_list_product" . " WHERE (cody_pick_list_product.pick_list_product_id IN ('1','2','3'))" . " AND (cody_pick_list_product.pick_list_product_amount_status <> 'decreased')" . " GROUP BY product_variant_id" . ") plp ON plp.product_variant_id = cody_product_variant.product_variant_id" . " INNER JOIN cody_pick_list_product ON cody_pick_list_product.product_variant_id = cody_product_variant.product_variant_id" . " AND cody_pick_list_product.pick_list_product_id IN ('1','2','3')" . " AND cody_pick_list_product.pick_list_product_amount_status <> 'decreased'" . " LEFT JOIN cody_order_product ON cody_order_product.order_product_id = cody_pick_list_product.order_product_id", $q); $q = SQL::table('cody_import_product')->leftJoin(SQL::table('cody_import_product_check')->on('import_task_id')->on('import_product_row'))->whereNull('cody_import_product_check.import_product_row')->make(); $this->assertEquals('SELECT * FROM cody_import_product' . ' LEFT JOIN cody_import_product_check' . ' ON cody_import_product_check.import_task_id = cody_import_product.import_task_id' . ' AND cody_import_product_check.import_product_row = cody_import_product.import_product_row' . ' WHERE (cody_import_product_check.import_product_row IS NULL)', $q); /* $pickListProductIds = array(1,2,3); SQL::table('cody_product_variant') ->innerJoin( SQL::subquery( SQL::table('cody_pick_list_product') ->whereBy('pick_list_product_id', $pickListProductIds) ->whereNotBy('pick_list_product_amount_status', 'decreased') ->groupBy('product_variant_id') ) ->alias('plp') ->on('product_variant_id') ) ->innerJoin( SQL::table('cody_pick_list_product') ->on('product_variant_id') ->onBy('pick_list_product_id', $pickListProductIds) ->onNotBy('pick_list_product_amount_status', 'decreased') ->leftJoin( SQL::table('cody_order_product')->on('order_product_id') ) ) ->updateOperation("cody_product_variant.".$amountField." = cody_product_variant.".$amountField." - IF(cody_product_variant.product_variant_stock = 'backorder', 0, plp.pick_list_product_amount), cody_pick_list_product.pick_list_product_amount_status = 'decreased', cody_order_product.$statusField = 'none'"); $q = "UPDATE cody_product_variant INNER JOIN ( SELECT product_variant_id, SUM(pick_list_product_amount) as pick_list_product_amount FROM cody_pick_list_product WHERE cody_pick_list_product.pick_list_product_id IN ('".join("','", $pickListProductIds)."') AND cody_pick_list_product.pick_list_product_amount_status <> 'decreased' GROUP BY cody_pick_list_product.product_variant_id ) as plp ON cody_product_variant.product_variant_id = plp.product_variant_id INNER JOIN cody_pick_list_product ON cody_pick_list_product.product_variant_id = cody_product_variant.product_variant_id AND cody_pick_list_product.pick_list_product_id IN ('".join("','", $pickListProductIds)."') AND cody_pick_list_product.pick_list_product_amount_status <> 'decreased' LEFT JOIN cody_order_product ON cody_order_product.order_product_id = cody_pick_list_product.order_product_id SET cody_product_variant.".$amountField." = cody_product_variant.".$amountField." - IF(cody_product_variant.product_variant_stock = 'backorder', 0, plp.pick_list_product_amount), cody_pick_list_product.pick_list_product_amount_status = 'decreased', cody_order_product.$statusField = 'none'"; */ }