protected function display() { // Admins only if (Tools::isConnectedUser()) { $session_user = UserCache::getInstance()->getUser($_SESSION['userid']); if ($session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) { $this->smartyHelper->assign('defaultColor', Holidays::$defaultColor); if (isset($_POST['hol_color'])) { $formatedDate = Tools::getSecurePOSTStringValue('date'); $timestamp = Tools::date2timestamp($formatedDate); $hol_desc = Tools::getSecurePOSTStringValue('hol_desc'); $hol_color = Tools::getSecurePOSTStringValue('hol_color'); if (!Holidays::save($timestamp, $hol_desc, $hol_color)) { $this->smartyHelper->assign('error', T_("Couldn't add the holiday")); } } elseif (isset($_POST['hol_id'])) { $hol_id = Tools::getSecurePOSTIntValue('hol_id'); if (!Holidays::delete($hol_id)) { $this->smartyHelper->assign('error', T_("Couldn't remove the holiday")); } } $this->smartyHelper->assign('holidays', Holidays::getHolidays()); } } }
public static function addSeasonHolidays($inputs, $seasondata) { for ($i = 0; $i < count($inputs); $i++) { $holiday = new Holidays(); $holiday->season_id = $seasondata['id']; $holiday->franchisee_id = $seasondata['franchisee_id']; $holiday->created_by = Session::get('userId'); $holiday->created_at = date("Y-m-d H:i:s"); $holiday->startdate = $inputs[$i]['startdate']; $holiday->enddate = $inputs[$i]['enddate']; $holiday->title = $inputs[$i]['title']; $holiday->save(); } return $holiday; }