/** * Add and Update Holiday * @param Holiday $holiday * @return boolean */ public function saveHoliday(Holiday $holiday) { try { $holiday->save(); return $holiday; } catch (Exception $e) { throw new DaoException($e->getMessage()); } }
public function processDeleteAction() { $id = (int) $this->_getParam('id'); $holiday = new Holiday(); $holiday->holidayId = $id; $holiday->setPersistMode(WebVista_Model_ORM::DELETE); $holiday->persist(); $data = true; $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }
/** * Implementation for 'POST' method for Rest API * * @param mixed $hldUid Primary key * * @return array $result Returns array within multiple records or a single record depending if * a single selection was requested passing id(s) as param */ protected function post($hldUid, $hldDate, $hldDescription) { try { $result = array(); $obj = new Holiday(); $obj->setHldUid($hldUid); $obj->setHldDate($hldDate); $obj->setHldDescription($hldDescription); $obj->save(); } catch (Exception $e) { throw new RestException(412, $e->getMessage()); } }
public function actionCreate() { $model = new Holiday('insert'); $semester = Semesters::model()->actual(); if (Yii::app()->request->isPostRequest) { $holiday = Yii::app()->request->getParam('Holiday'); $model->setAttributes($holiday); if ($model->save()) { Yii::app()->user->setFlash('success', 'Выходной успешно создан'); $this->redirect(['index']); } } $this->render('form', ['model' => $model, 'semester' => $semester]); }
public function actionTest($id) { // renders the view file 'protected/views/screen/display.php' // using the default layout 'protected/views/layouts/billboard.php' $this->screen_id = $id; $screen = Screen::model()->findByPk($id); if ($screen === null) { throw new CHttpException(404, Yii::t('error', 'The requested screen does not exist.')); } Yii::app()->theme = count($screen->themes) == 0 ? 'he' : $screen->themes[0]->theme; $conditions = array(); $conditions[] = 'ads.expire>=:now'; $conditions[] = 'ads.start<=:now'; $conditions[] = 'ads.' . date('D', strtotime('now')) . '=1'; $ads = $screen->ads(array('condition' => implode(' AND ', $conditions), 'params' => array(':now' => date('Y-m-d', strtotime('now'))))); $yeshuv = $screen->yeshuv->name_heb; $commercial = $screen->commercials[0]->file_name; date_default_timezone_set('Asia/Jerusalem'); if ($this->isweekend()) { $holiday = Holiday::model()->find(array('condition' => 'name = :name', 'params' => array(':name' => 'friday'))); } else { $holiday = Holiday::model()->find(array('condition' => 'end_date >= :now && start_date <= :now', 'params' => array(':now' => date('Y-m-d H:i:s', strtotime('now'))))); } $this->render('test', array('ads' => $ads, 'screen' => $screen, 'yeshuv' => $yeshuv, 'commercial' => 5, 'holiday' => $holiday)); }
public static function updateHoliday($data, $id) { $holiday = Holiday::find($id); $holiday->name = array_get($data, 'name'); $holiday->date = array_get($data, 'date'); $holiday->update(); }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Holiday::create([]); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('holidays')->delete(); $db = App::make('AccessDB'); $query = new Query('HOLIDAYS', $db->get_dbh()); $query->where('DURATION', '>', 0); $result = $query->get('HOLIDAYID,STARTTIME,DURATION'); $result_array = []; foreach ($result as $row) { $start_time = strtotime($row['STARTTIME']); $duration = $row['DURATION'] - 1; $end_time = strtotime("+{$duration} days", $start_time); $result_array[] = ['id' => $row['HOLIDAYID'], 'start' => $row['STARTTIME'], 'duration' => $row['DURATION'], 'end' => date('Y-m-d H:i:s', $end_time)]; } $holiday = array_chunk($result_array, 1000); foreach ($holiday as $value) { Holiday::insert($value); } $convert_file = public_path() . '\\Last Convert.txt'; $record = explode(';', file_get_contents($convert_file)); $record[2] = $result[count($result) - 1]['HOLIDAYID']; $file = fopen($convert_file, 'w'); fwrite($file, implode(';', $record)); fclose($file); }
public function updateHoliday($id) { $holiday = Holiday::find($id); $holiday->name = Input::get('name'); $holiday->date = Input::get('date'); $holiday->save(); return Redirect::back()->with('message', array('type' => 'success', 'text' => 'Updated Holiday!')); }
public function actionHoliday() { date_default_timezone_set('Asia/Jerusalem'); $holiday = Holiday::model()->find(array('condition' => 'end_date >= :now && start_date <= :now', 'params' => array(':now' => date('Y-m-d H:i:s', strtotime('now'))))); if ($holiday) { ScreenAjax::model()->updateAll(array('refresh' => 1)); } }
public static function is_holiday($date) { $holiday = Holiday::where('start', '<=', $date)->where('end', '>=', $date)->count(); if ($holiday > 0) { return 1; } else { return 0; } }
public function holidays($start) { $query = new Query('HOLIDAYS', $this->dbh); $query->where('HOLIDAYID', '>', $start); $result = $query->get('HOLIDAYID,STARTTIME,DURATION'); foreach ($result as $row) { $start_time = strtotime($row['STARTTIME']); $duration = $row['DURATION'] - 1; $end_time = strtotime("+{$duration} days", $start_time); Holiday::create(['id' => $row['HOLIDAYID'], 'start' => $row['STARTTIME'], 'duration' => $row['DURATION'], 'end' => date('Y-m-d H:i:s', $end_time)]); } $size = count($result); $this->num_data += $size; return $size > 0 ? $result[$size - 1]['HOLIDAYID'] : $start; }
/** * Resets all references to other model objects or collections of model objects. * * This method is a user-space workaround for PHP's inability to garbage collect * objects with circular references (even in PHP 5.3). This is currently necessary * when using Propel in certain daemon or large-volumne/high-memory operations. * * @param boolean $deep Whether to also clear the references on all referrer objects. */ public function clearAllReferences($deep = false) { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; if ($this->aDomain instanceof Persistent) { $this->aDomain->clearAllReferences($deep); } if ($this->aHoliday instanceof Persistent) { $this->aHoliday->clearAllReferences($deep); } $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aDomain = null; $this->aHoliday = null; }
/** * @param Holiday $holiday The holiday object to add. */ protected function doAddHoliday($holiday) { $this->collHolidays[] = $holiday; $holiday->setAccount($this); }
$langs->load('users'); $langs->load('holidays'); $langs->load('trips'); $socid = GETPOST("socid"); // Protection if external user if ($user->societe_id > 0) { accessforbidden(); } /* * Actions */ // None /* * View */ $holiday = new Holiday($db); $holidaystatic = new Holiday($db); $childids = $user->getAllChildIds(); $childids[] = $user->id; llxHeader(array(), $langs->trans('HRMArea')); print_fiche_titre($langs->trans("HRMArea")); print '<div class="fichecenter"><div class="fichethirdleft">'; if (!empty($conf->holiday->enabled)) { $user_id = $user->id; $nbaquis = $holiday->getCPforUser($user_id); $nbdeduced = $holiday->getConfCP('nbHolidayDeducted'); $nb_holiday = $nbaquis / $nbdeduced; print '<table class="noborder nohover" width="100%">'; print '<tr class="liste_titre"><td colspan="3">' . $langs->trans("Holidays") . '</td></tr>'; print "<tr " . $bc[0] . ">"; print '<td colspan="3">';
exit; } header('Location: fiche.php?id=' . $_GET['id']); exit; } else { // Sinon on affiche le formulaire de demande avec le message d'erreur SQL header('Location: fiche.php?id=' . $_GET['id'] . '&error=SQL_Create&msg=' . $cp->error); exit; } } } /* * View */ $form = new Form($db); $cp = new Holiday($db); $listhalfday = array('morning' => $langs->trans("Morning"), "afternoon" => $langs->trans("Afternoon")); llxHeader(array(), $langs->trans('CPTitreMenu')); if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create') { // Si l'utilisateur n'a pas le droit de faire une demande if ($userid == $user->id && empty($user->rights->holiday->write) || $userid != $user->id && empty($user->rights->holiday->write_all)) { $errors[] = $langs->trans('CantCreateCP'); } else { // Formulaire de demande de congés payés print_fiche_titre($langs->trans('MenuAddCP')); // Si il y a une erreur if (GETPOST('error')) { switch (GETPOST('error')) { case 'datefin': $errors[] = $langs->trans('ErrorEndDateCP'); break;
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Holiday $obj A Holiday object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null HolidayPeer::$instances[$key] = $obj; } }
accessforbidden(); } // Si l'utilisateur n'a pas le droit de lire cette page if (!$user->rights->holiday->read_all) { accessforbidden(); } $year = GETPOST('year'); if (empty($year)) { $tmpdate = dol_getdate(dol_now()); $year = $tmpdate['year']; } $langs->load('users'); /* * View */ $cp = new Holiday($db); llxHeader(array(), $langs->trans('CPTitreMenu') . ' (' . $langs->trans("Year") . ' ' . $year . ')'); // Recent changes are more important than old changes $log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC', " AND date_action BETWEEN '" . $db->idate(dol_get_first_day($year, 1, 1)) . "' AND '" . $db->idate(dol_get_last_day($year, 12, 1)) . "'"); // Load $cp->logs print load_fiche_titre($langs->trans('LogCP'), '<div class="pagination"><ul><li class="pagination"><a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year - 1) . '"><</a><li class="pagination"><a href="">' . $langs->trans("Year") . ' ' . $year . '</a></li><li class="pagination"><a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year + 1) . '">></a></li></lu></div>', 'title_hrm.png'); print '<div class="info">' . $langs->trans('LastUpdateCP') . ': ' . "\n"; if ($cp->getConfCP('lastUpdate')) { print '<strong>' . dol_print_date($db->jdate($cp->getConfCP('lastUpdate')), 'dayhour', 'tzuser') . '</strong>'; } else { print $langs->trans('None'); } print "</div><br>\n"; print '<table class="noborder" width="100%">'; print '<tbody>'; print '<tr class="liste_titre">';
public function calcClockings(&$list, $userid, $start, $end) { $this->employee = UserQuery::create()->filterById($userid)->findOne(); $domain = $this->employee->getDomain(); $vacationDays = HolidayQuery::create()->filterByDomain($domain)->filterByDate($start, Criteria::GREATER_EQUAL)->filterByDate($end, Criteria::LESS_EQUAL)->find(); $this->holidays = array(); foreach ($vacationDays as $day) { $key = dayKey($day->getDate()); $this->holidays[$key] = $day; } // Get flexitime $this->flexitime = ClockingQuery::create()->filterByUserId($userid)->filterByStart($start, Criteria::LESS_THAN)->filterByVisibility(0)->withColumn('SUM(flexitime)', 'flexitimeSum')->findOne()->getFlexitimeSum(); $this->holidaysWeeks = Holiday::getCountPerWeek($domain, $start, $end); // Calculate weektime for first item $first = $list->getFirst(); if ($first == null) { // No items at all, stop here return; } $weekday = date('N', $first->getStart()); $currentWeek = date('W', $first->getStart()); $currentYear = date('Y', $first->getStart()); // Count any holiday as 'work done' $weekKey = $currentWeek . '-' . $currentYear; if (!array_key_exists($weekKey, $this->holidaysWeeks)) { $this->holidaysWeeks[$weekKey] = 0; } $this->worktime = $this->holidaysWeeks[$weekKey] * $this->employee->getDailyTime(); if ($weekday > 1) { $weekstart = createDate($first->getStart()); $weekstart->modify('midnight this week'); $weekend = createDate($first->getStart()); $weekend->modify('midnight this week +7 days'); $week = ClockingQuery::create()->filterByStart($weekstart->getTimestamp(), Criteria::GREATER_THAN)->filterByStart($weekend->getTimestamp(), Criteria::LESS_THAN)->filterByUser($this->employee)->filterByVisibility(0)->find(); $this->calcList($week); } $connection = Propel::getConnection(ClockingPeer::DATABASE_NAME); $connection->beginTransaction(); try { $this->calcList($list); $connection->commit(); } catch (Exception $e) { $connection->rollBack(); throw $e; } }
$month_start = GETPOST('month_start'); $year_start = GETPOST('year_start'); $month_end = GETPOST('month_end'); $year_end = GETPOST('year_end'); $search_employe = GETPOST('search_employe'); $search_valideur = GETPOST('search_valideur'); $search_statut = GETPOST('select_statut'); /* * Actions */ // None /* * View */ $holiday = new Holiday($db); $holidaystatic = new Holiday($db); $fuser = new User($db); // Update sold $holiday->updateSold(); $max_year = 5; $min_year = 10; $filter = ''; llxHeader(array(), $langs->trans('CPTitreMenu')); $order = $db->order($sortfield, $sortorder) . $db->plimit($conf->liste_limit + 1, $offset); // WHERE if (!empty($search_ref)) { $filter .= " AND cp.rowid LIKE '%" . $db->escape($search_ref) . "%'\n"; } // DATE START if ($year_start > 0) { if ($month_start > 0) {
/** * Show holidays for a calendar * * @param $calendar Calendar object **/ static function showForCalendar(Calendar $calendar) { global $DB, $CFG_GLPI; $ID = $calendar->getField('id'); if (!$calendar->can($ID, 'r')) { return false; } $canedit = $calendar->can($ID, 'w'); $rand = mt_rand(); $query = "SELECT DISTINCT `glpi_calendars_holidays`.`id` AS linkID,\n `glpi_holidays`.*\n FROM `glpi_calendars_holidays`\n LEFT JOIN `glpi_holidays`\n ON (`glpi_calendars_holidays`.`holidays_id` = `glpi_holidays`.`id`)\n WHERE `glpi_calendars_holidays`.`calendars_id` = '{$ID}'\n ORDER BY `glpi_holidays`.`name`"; $result = $DB->query($query); $holidays = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $holidays[$data['id']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='calendarsegment_form{$rand}' id='calendarsegment_form{$rand}' method='post'\n action='"; echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add a close time') . "</tr>"; echo "<tr class='tab_bg_2'><td class='right' colspan='4'>"; echo "<input type='hidden' name='calendars_id' value='{$ID}'>"; Holiday::dropdown(array('used' => $used, 'entity' => $calendar->fields["entities_id"])); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $paramsma = array('num_displayed' => $numrows); Html::showMassiveActions(__CLASS__, $paramsma); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; if ($canedit && $numrows) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Start') . "</th>"; echo "<th>" . __('End') . "</th>"; echo "<th>" . __('Recurrent') . "</th>"; echo "</tr>"; $used = array(); if ($numrows) { Session::initNavigateListItems('Holiday', sprintf(__('%1$s = %2$s'), Calendar::getTypeName(1), $calendar->fields["name"])); foreach ($holidays as $data) { Session::addToNavigateListItems('Holiday', $data["id"]); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]); echo "</td>"; } echo "<td><a href='" . Toolbox::getItemTypeFormURL('Holiday') . "?id=" . $data['id'] . "'>" . $data["name"] . "</a></td>"; echo "<td>" . Html::convDate($data["begin_date"]) . "</td>"; echo "<td>" . Html::convDate($data["end_date"]) . "</td>"; echo "<td>" . Dropdown::getYesNo($data["is_perpetual"]) . "</td>"; echo "</tr>"; } } echo "</table>"; if ($canedit && $numrows) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; }
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/holiday/common.inc.php'; // Protection if external user if ($user->societe_id > 0) { accessforbidden(); } // Si l'utilisateur n'a pas le droit de lire cette page if (!$user->rights->holiday->month_report) { accessforbidden(); } /* * View */ $html = new Form($db); $htmlother = new FormOther($db); $holidaystatic = new Holiday($db); llxHeader(array(), $langs->trans('CPTitreMenu')); $cp = new Holiday($db); $month = GETPOST('month_start'); $year = GETPOST('year_start'); if (empty($month)) { $month = date('n'); } if (empty($year)) { $year = date('Y'); } $sql = "SELECT cp.rowid, cp.fk_user, cp.date_debut, cp.date_fin, cp.halfday"; $sql .= " FROM " . MAIN_DB_PREFIX . "holiday cp"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user u ON cp.fk_user = u.rowid"; $sql .= " WHERE cp.statut = 3"; // Approved
// Show the login form Route::get('/users/login', array('as' => 'usersLogin', 'uses' => 'UsersController@showLogin')); // Process the login form Route::post('/users/login', array('as' => 'processLogin', 'uses' => 'UsersController@doLogin')); // Logging Out Route::get('users/logout', array('uses' => 'UsersController@doLogout')); Route::get('/employee/servertime', array('before' => 'auth', 'as' => 'updateServerTime', 'uses' => 'EmployeesController@updateServerTime')); Route::get('/employee/serverdatetime', array('before' => 'auth', 'as' => 'getServerDateTime', 'uses' => 'EmployeesController@getServerDateTime')); Route::get('/employee/clocking', array('before' => 'auth', 'as' => 'employeeTimesheet', 'uses' => 'EmployeesController@showEmployeeTimesheet')); Route::post('/employee/clocking', array('as' => 'timeClocking', 'uses' => function () { $data = Input::all(); echo Session::put('timeclocking', $data['timeclocking']); $workShift = new Workshift(); $getWorkShift = $workShift->getWorkShiftByEmployeeId(Auth::user()->employee_id); $todayDate = date('Y-m-d'); $holiday = new Holiday(); $getHolidayByDate = $holiday->getHolidayByDate($todayDate); //var_dump($employeeClocking); //$employeeId = Auth::user()->employee_id; //$workShift = DB::table('work_shift')->where('employee_id', $employeeId)->get(); $timesheet = new Timesheet(); $getTimesheetById = $timesheet->getTimesheetById(Auth::user()->employee_id, date('Y-m-d')); $schedule = new Schedule(); $hasSchedule = $schedule->checkSchedule(Auth::user()->employee_id, date('Y-m-d')); $getSchedule = $schedule->getSchedule(Auth::user()->employee_id, date('Y-m-d')); //Deduction Model $deduction = new Deduction(); $hasNightShiftStartTimeThreshold = true; $nightShiftStartTimeThreshold = 5; //It should be bigger; //get schedule
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT . '/holiday/common.inc.php'; // Protection if external user if ($user->societe_id > 0) { accessforbidden(); } // Si l'utilisateur n'a pas le droit de lire cette page if (!$user->rights->holiday->view_log) { accessforbidden(); } /* * View */ $langs->load('users'); llxHeader(array(), $langs->trans('CPTitreMenu')); $cp = new Holiday($db); // Recent changes are more important than old changes $log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC', ''); print_fiche_titre($langs->trans('LogCP')); print '<table class="noborder" width="100%">'; print '<tbody>'; print '<tr class="liste_titre">'; print '<td class="liste_titre">' . $langs->trans('ID') . '</td>'; print '<td class="liste_titre" align="center">' . $langs->trans('Date') . '</td>'; print '<td class="liste_titre">' . $langs->trans('ActionByCP') . '</td>'; print '<td class="liste_titre">' . $langs->trans('UserUpdateCP') . '</td>'; print '<td class="liste_titre">' . $langs->trans('Description') . '</td>'; print '<td class="liste_titre" align="right">' . $langs->trans('PrevSoldeCP') . '</td>'; print '<td class="liste_titre" align="right">' . $langs->trans('NewSoldeCP') . '</td>'; print '</tr>'; $var = true;
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'duplicate': // For calendar duplicate in another entity if (method_exists($item, 'duplicate')) { $input = $ma->getInput(); $options = array(); if ($item->isEntityAssign()) { $options = array('entities_id' => $input['entities_id']); } foreach ($ids as $id) { if ($item->getFromDB($id)) { if (!$item->isEntityAssign() || $input['entities_id'] != $item->getEntityID()) { if ($item->can(-1, CREATE, $options)) { if ($item->duplicate($options)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_COMPAT)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND)); } } } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } return; case 'addholiday': // add an holiday with massive action $input = $ma->getInput(); if ($input['holidays_id'] > 0) { $holiday = new Holiday(); $calendar_holiday = new Calendar_Holiday(); $holiday->getFromDB($input['holidays_id']); $entities = array($holiday->getEntityID() => $holiday->getEntityID()); if ($holiday->isRecursive()) { $entities = getSonsOf("glpi_entities", $holiday->getEntityID()); } foreach ($ids as $id) { $entities_id = CommonDBTM::getItemEntity('Calendar', $id); if (isset($entities[$entities_id])) { $input = array('calendars_id' => $id, 'holidays_id' => $input['holidays_id']); if ($calendar_holiday->add($input)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); } } } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
exit; } header('Location: card.php?id=' . $_GET['id']); exit; } else { // Sinon on affiche le formulaire de demande avec le message d'erreur SQL header('Location: card.php?id=' . $_GET['id'] . '&error=SQL_Create&msg=' . $cp->error); exit; } } } /* * View */ $form = new Form($db); $cp = new Holiday($db); $listhalfday = array('morning' => $langs->trans("Morning"), "afternoon" => $langs->trans("Afternoon")); llxHeader(array(), $langs->trans('CPTitreMenu')); if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create') { // Si l'utilisateur n'a pas le droit de faire une demande if ($userid == $user->id && empty($user->rights->holiday->write) || $userid != $user->id && empty($user->rights->holiday->write_all)) { $errors[] = $langs->trans('CantCreateCP'); } else { // Formulaire de demande de congés payés print load_fiche_titre($langs->trans('MenuAddCP'), '', 'title_hrm.png'); // Si il y a une erreur if (GETPOST('error')) { switch (GETPOST('error')) { case 'datefin': $errors[] = $langs->trans('ErrorEndDateCP'); break;
function generateTimeperiodsCfg($file=0) { PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "Starting generateTimeperiodsCfg ...\n" ); $calendar = new Calendar(); $calendarSegment = new CalendarSegment(); $calendar_Holiday = new Calendar_Holiday(); $holiday = new Holiday(); $a_timeperiods = array(); $i=0; $a_listcalendar = $calendar->find(); foreach ($a_listcalendar as $datacalendar) { $a_timeperiods[$i]['timeperiod_name'] = $datacalendar['name']; $a_timeperiods[$i]['alias'] = $datacalendar['name']; $a_listsegment = $calendarSegment->find("`calendars_id`='".$datacalendar['id']."'"); $a_cal = array(); foreach ($a_listsegment as $datasegment) { $begin = preg_replace("/:00$/", "", $datasegment['begin']); $end = preg_replace("/:00$/", "", $datasegment['end']); $day = ""; switch ($datasegment['day']) { case "0": $day = "sunday"; break; case "1": $day = "monday"; break; case "2": $day = "tuesday"; break; case "3": $day = "wednesday"; break; case "4": $day = "thursday"; break; case "5": $day = "friday"; break; case "6": $day = "saturday"; break; } $a_cal[$day][] = $begin."-".$end; } foreach ($a_cal as $day=>$a_times) { $a_timeperiods[$i][$day] = implode(',', $a_times); } $a_cholidays = $calendar_Holiday->find("`calendars_id`='".$datacalendar['id']."'"); foreach ($a_cholidays as $a_choliday) { $holiday->getFromDB($a_choliday['holidays_id']); if ($holiday->fields['is_perpetual'] == 1 && $holiday->fields['begin_date'] == $holiday->fields['end_date']) { $datetime = strtotime($holiday->fields['begin_date']); $a_timeperiods[$i][strtolower(date('F', $datetime)). ' '.date('j', $datetime)] = '00:00-00:00'; } } $i++; } PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "End generateTimeperiodsCfg\n" ); if ($file == "1") { $config = "# Generated by plugin monitoring for GLPI\n# on ".date("Y-m-d H:i:s")."\n\n"; foreach ($a_timeperiods as $data) { $config .= $this->writeFile("timeperiod", $data); } return array('timeperiods.cfg', $config); } else { return $a_timeperiods; } }
function getObjectStructure() { return Holiday::getObjectStructure(); }
$result = $object->fetch($id); if ($result <= 0) { dol_print_error($db, 'Failed to load object'); } $dir = $conf->product->multidir_output[$object->entity]; // By default if ($object->type == Product::TYPE_PRODUCT) { $dir = $conf->product->multidir_output[$object->entity]; } if ($object->type == Product::TYPE_SERVICE) { $dir = $conf->service->multidir_output[$object->entity]; } } } elseif ($modulepart == 'holiday') { require_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php'; $object = new Holiday($db); if ($id > 0) { $result = $object->fetch($id); if ($result <= 0) { dol_print_error($db, 'Failed to load object'); } $dir = $conf->holiday->dir_output; // By default } } /* * Actions */ if ($cancel) { if ($backtourl) { header("Location: " . $backtourl);
public function __get($name) { if ($name == "holidays") { if (!isset($this->holidays) && $this->libraryId) { $this->holidays = array(); $holiday = new Holiday(); $holiday->libraryId = $this->libraryId; $holiday->orderBy('date'); $holiday->find(); while ($holiday->fetch()) { $this->holidays[$holiday->id] = clone $holiday; } } return $this->holidays; } elseif ($name == "nearbyBookStores") { if (!isset($this->nearbyBookStores) && $this->libraryId) { $this->nearbyBookStores = array(); $store = new NearbyBookStore(); $store->libraryId = $this->libraryId; $store->orderBy('weight'); $store->find(); while ($store->fetch()) { $this->nearbyBookStores[$store->id] = clone $store; } } return $this->nearbyBookStores; } elseif ($name == "moreDetailsOptions") { if (!isset($this->moreDetailsOptions) && $this->libraryId) { $this->moreDetailsOptions = array(); $moreDetailsOptions = new LibraryMoreDetails(); $moreDetailsOptions->libraryId = $this->libraryId; $moreDetailsOptions->orderBy('weight'); $moreDetailsOptions->find(); while ($moreDetailsOptions->fetch()) { $this->moreDetailsOptions[$moreDetailsOptions->id] = clone $moreDetailsOptions; } } return $this->moreDetailsOptions; } elseif ($name == "facets") { if (!isset($this->facets) && $this->libraryId) { $this->facets = array(); $facet = new LibraryFacetSetting(); $facet->libraryId = $this->libraryId; $facet->orderBy('weight'); $facet->find(); while ($facet->fetch()) { $this->facets[$facet->id] = clone $facet; } } return $this->facets; } elseif ($name == 'searchSources') { if (!isset($this->searchSources) && $this->libraryId) { $this->searchSources = array(); $searchSource = new LibrarySearchSource(); $searchSource->libraryId = $this->libraryId; $searchSource->orderBy('weight'); $searchSource->find(); while ($searchSource->fetch()) { $this->searchSources[$searchSource->id] = clone $searchSource; } } return $this->searchSources; } elseif ($name == 'libraryLinks') { if (!isset($this->libraryLinks) && $this->libraryId) { $this->libraryLinks = array(); $libraryLink = new LibraryLinks(); $libraryLink->libraryId = $this->libraryId; $libraryLink->orderBy('weight'); $libraryLink->find(); while ($libraryLink->fetch()) { $this->libraryLinks[$libraryLink->id] = clone $libraryLink; } } return $this->libraryLinks; } elseif ($name == 'libraryTopLinks') { if (!isset($this->libraryTopLinks) && $this->libraryId) { $this->libraryTopLinks = array(); $libraryLink = new LibraryTopLinks(); $libraryLink->libraryId = $this->libraryId; $libraryLink->orderBy('weight'); $libraryLink->find(); while ($libraryLink->fetch()) { $this->libraryTopLinks[$libraryLink->id] = clone $libraryLink; } } return $this->libraryTopLinks; } elseif ($name == 'browseCategories') { if (!isset($this->browseCategories) && $this->libraryId) { $this->browseCategories = array(); $browseCategory = new LibraryBrowseCategory(); $browseCategory->libraryId = $this->libraryId; $browseCategory->orderBy('weight'); $browseCategory->find(); while ($browseCategory->fetch()) { $this->browseCategories[$browseCategory->id] = clone $browseCategory; } } return $this->browseCategories; } else { return $this->data[$name]; } }