Example #1
0
 /**
  * Insert leave details to Employeelogs
  * 
  * @param date $leavedate
  * @param Employeeleavesfiled $empleave
  * @return void
  */
 private function _inserttoemplogs($leavedate, Employeeleavesfiled $empleave)
 {
     $schedule = new Schedules();
     $emplogs = new Employeelogs();
     $schedule->Date = '\'' . $leavedate . ' 00:00:00\'';
     $schedule->EmployeeNumber = $empleave->EmployeeNumber;
     $sched = $schedule->get();
     if (isset($sched) && !empty($sched)) {
         $emplogs->EmployeeNumber = '\'' . $empleave->EmployeeNumber . '\'';
         $emplogs->ScheduleID = $sched[0]->ScheduleID;
         $emplogs->TimeIn = '\'' . $sched[0]->SchedIn . '\'';
         $emplogs->Timeout = '\'' . $sched[0]->SchedOut . '\'';
         $emplogs->EarlyLogin = 1;
         $emplogs->AttendanceType = '\'' . $empleave->Type . '\'';
         $emplogs->LeaveFiledID = $empleave->LeaveID;
         $emplogs->insert();
     }
 }
 /**
  * Function to run when the schedule cron fires.
  *
  * @param $schedule_id
  */
 public function schedule_hook_run($schedule_id)
 {
     if (!hmbkp_possible()) {
         return;
     }
     $schedules = Schedules::get_instance();
     $schedule = $schedules->get_schedule($schedule_id);
     if (!$schedule) {
         return;
     }
     $schedule->run();
 }
 public function save_changed_walker()
 {
     $walk_id = Input::get('walk_id');
     $type = Input::get('type');
     $walker_id = Input::get('walker_id');
     $walk = Walk::find($walk_id);
     if ($type == 1) {
         $walk->walker_id = $walker_id;
         $walk->save();
     } else {
         Walk::where('schedule_id', $walk->schedule_id)->where('is_started', 0)->update(array('walker_id' => $walker_id));
         Schedules::where('id', $walk->schedule_id)->update(array('walker_id' => $walker_id));
     }
     return Redirect::to('/admin/walk/change_walker/' . $walk_id);
 }
<?php

namespace HM\BackUpWordPress;

if (Schedules::get_instance()->get_schedule($schedule->get_id())) {
    ?>

	<div class="hmbkp-schedule-actions row-actions">

		<a class="hmbkp-run" href="<?php 
    echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'hmbkp_run_schedule', 'hmbkp_schedule_id' => $schedule->get_id()), admin_url('admin-ajax.php')), 'hmbkp_run_schedule', 'hmbkp_run_schedule_nonce'));
    ?>
"><?php 
    _e('Run now', 'backupwordpress');
    ?>
</a>  |

		<a href="<?php 
    echo esc_url(add_query_arg(array('action' => 'hmbkp_edit_schedule', 'hmbkp_panel' => 'hmbkp_edit_schedule_settings', 'hmbkp_schedule_id' => $schedule->get_id()), get_settings_url()), 'hmbkp-edit-schedule');
    ?>
"><?php 
    _e('Settings', 'backupwordpress');
    ?>
</a> |

		<?php 
    // Only show excludes if we are backing up files
    if ('database' !== $schedule->get_type()) {
        ?>
			<a href="<?php 
        echo esc_url(add_query_arg(array('action' => 'hmbkp_edit_schedule', 'hmbkp_panel' => 'hmbkp_edit_schedule_excludes', 'hmbkp_schedule_id' => $schedule->get_id()), get_settings_url()));
Example #5
0
 /**
  * Gets the settings for a similar destination from the existing schedules
  * so that we can copy them into the form to avoid having to type them again
  *
  * @return array
  */
 protected function fetch_destination_settings()
 {
     $service = $this->get_slug();
     $schedules_obj = Schedules::get_instance();
     $schedules = $schedules_obj->get_schedules();
     foreach ($schedules as $schedule) {
         if ($schedule->get_id() != $this->schedule->get_id()) {
             $options = $schedule->get_service_options($service);
             if (!empty($options)) {
                 return $options;
             }
         }
     }
     return array();
 }
Example #6
0
    echo esc_html(translated_schedule_title($schedule->get_slug(), $schedule->get_name()));
    ?>
 <span class="count">(<?php 
    echo esc_html(count($schedule->get_backups()));
    ?>
)</span></a></li>

		<?php 
}
?>

		<li><a href="<?php 
echo esc_url(add_query_arg(array('hmbkp_add_schedule' => '1', 'action' => 'hmbkp_edit_schedule', 'hmbkp_schedule_id' => time(), 'hmbkp_panel' => 'hmbkp_edit_schedule_settings'), HMBKP_ADMIN_URL));
?>
" class="<?php 
if (!Schedules::get_instance()->get_schedule($current_schedule->get_id())) {
    ?>
 current<?php 
}
?>
"> + <?php 
_e('add schedule', 'backupwordpress');
?>
</a></li>

	</ul>
</div>

<?php 
// Don't continue if we don't have a schedule
if (!($schedule = $current_schedule)) {
 /**
  * @return array
  */
 public static function test()
 {
     $backup_sizes = array();
     $schedules = Schedules::get_instance();
     foreach ($schedules->get_schedules() as $schedule) {
         $site_size = new Site_Size($schedule->get_type(), $schedule->get_excludes());
         if ($site_size->is_site_size_cached()) {
             $backup_sizes[$schedule->get_type()] = $site_size->get_formatted_site_size();
         }
     }
     return $backup_sizes;
 }
/**
 * Setup the default backup schedules
 */
function setup_default_schedules()
{
    $schedules = Schedules::get_instance();
    if ($schedules->get_schedules()) {
        return;
    }
    /**
     * Schedule a database backup daily and store backups
     * for the last 2 weeks
     */
    $database_daily = new Scheduled_Backup((string) time());
    $database_daily->set_type('database');
    $database_daily->set_schedule_start_time(determine_start_time('daily', array('hours' => '23', 'minutes' => '0')));
    $database_daily->set_reoccurrence('daily');
    $database_daily->set_max_backups(7);
    $database_daily->save();
    /**
     * Schedule a complete backup to run weekly and store backups for
     * the last 3 months
     */
    $complete_weekly = new Scheduled_Backup((string) (time() + 1));
    $complete_weekly->set_type('complete');
    $complete_weekly->set_schedule_start_time(determine_start_time('weekly', array('day_of_week' => 'sunday', 'hours' => '3', 'minutes' => '0')));
    $complete_weekly->set_reoccurrence('weekly');
    $complete_weekly->set_max_backups(3);
    $complete_weekly->save();
    $schedules->refresh_schedules();
    add_action('admin_notices', function () {
        echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has set up your default schedules.', 'backupwordpress') . '</strong> ' . __('By default BackUpWordPress performs a daily backup of your database and a weekly backup of your database &amp; files. You can modify these schedules.', 'backupwordpress') . '</p></div>';
    });
}
Example #9
0
 /**
  * @return array
  */
 protected function test()
 {
     $backup_sizes = array();
     $schedules = Schedules::get_instance();
     foreach ($schedules->get_schedules() as $schedule) {
         if ($schedule->is_site_size_cached()) {
             $backup_sizes[$schedule->get_id()] = $schedule->get_formatted_site_size();
         }
     }
     return $backup_sizes;
 }
Example #10
0
 /**
  * 
  * @param int $year year of the generating calendar
  * @param int $month month of the generating calendar
  * @param int $day Optional. Day of the generating calendar. Default empty
  * @param string $url Optional. Url of the page where generating calendar. Default empty
  * @param int $boardroom_id Optional. Boardroom id which is must be display on calendar. Default '1'
  * @param array $days Optional. Names of days to convert to any you want. Default empty array
  * @param int $day_name_length Optional. Lenth of name's days to display in calendar. Default '10'
  * @param string $month_href Optional. Link of month. Default NULL
  * @param int $first_day Optional. First day of week in calendar. Default '1' - Monday
  * @return string $calendar Html of calendar
  */
 function generateCalendar($year, $month, $day = '', $url = '', $boardroom_id = 1, $days = array(), $day_name_length = 10, $month_href = NULL, $first_day = 1)
 {
     $schedule = new Schedules();
     $boardroom_id = isset($_GET['boardroom_id']) ? $_GET['boardroom_id'] : 1;
     $url = '?boardroom_id=' . $boardroom_id;
     $first_of_month = gmmktime(0, 0, 0, $month, 1, $year);
     $day_names = array();
     #generate all the day names according to the current locale
     for ($n = 0, $t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400) {
         #January 4, 1970 was a Sunday
         $day_names[$n] = ucfirst(gmstrftime('%A', $t));
     }
     #%A means full textual day name
     list($month, $year, $month_name, $weekday) = explode(',', gmstrftime('%m,%Y,%B,%w', $first_of_month));
     $weekday = ($weekday + 7 - $first_day) % 7;
     #adjust for $first_day
     $title = htmlentities(ucfirst($month_name)) . '&nbsp;' . $year;
     #note that some locales don't capitalize month and day names
     $next_month = $month == 12 ? 1 : $month + 1;
     $prev_month = $month == 1 ? 12 : $month - 1;
     $next_year = $month == 12 ? $year + 1 : $year;
     $prev_year = $month == 1 ? $year - 1 : $year;
     $p = '<span class="calendar-prev"><a href="' . $url . '&year=' . $prev_year . '&month=' . $prev_month . '"><<</a></span>&nbsp;';
     $n = '&nbsp;<span class="calendar-next">' . '<a href="' . $url . '&year=' . $next_year . '&month=' . $next_month . '">>></a>' . '</span>';
     $calendar = '<table class="calendar">' . "\n" . '<caption class="calendar-month">' . $p . $title . $n . "</caption>\n<tr>";
     if ($day_name_length) {
         #if the day names should be shown ($day_name_length > 0)
         #if day_name_length is >3, the full name of the day will be printed
         foreach ($day_names as $d) {
             $calendar .= '<th abbr="' . htmlentities($d) . '">' . htmlentities($day_name_length < 4 ? substr($d, 0, $day_name_length) : $d) . '</th>';
         }
         $calendar .= "</tr>\n<tr>";
     }
     if ($weekday > 0) {
         for ($i = 0; $i < $weekday; $i++) {
             $calendar .= '<td>&nbsp;</td>';
             #initial 'empty' days
         }
     }
     for ($day = 1, $days_in_month = gmdate('t', $first_of_month); $day <= $days_in_month; $day++, $weekday++) {
         if ($weekday == 7) {
             $weekday = 0;
             #start a new week
             $calendar .= "</tr>\n<tr>";
         }
         $search_day = $day < 10 ? 0 . $day : $day;
         $search_date = $year . '-' . $month . '-' . $search_day;
         $list = $schedule->listAppointments($search_date, $boardroom_id);
         $calendar .= "<td>";
         $calendar .= "<p class='date-day' title='{$day} {$title}'>{$day}</p>";
         if ($list) {
             foreach ($list as $appointment) {
                 $from = explode(' ', $appointment['start_date']);
                 $from = substr($from[1], 0, 5);
                 $till = explode(' ', $appointment['end_date']);
                 $till = substr($till[1], 0, 5);
                 $calendar .= "<a class='appointment' data-id='" . $appointment['schedule_id'] . "' >" . $from . " - " . $till . "</a>";
             }
         }
         $calendar .= "</td>";
         unset($list);
     }
     if ($weekday != 7) {
         for ($i = 0; $i < 7 - $weekday; $i++) {
             //empty days
             $calendar .= '<td>&nbsp;</td>';
         }
     }
     return $calendar . "</tr>\n</table>\n";
 }
<?php

require_once "../../../inclusionfirst_api/connect_inclusion_first.php";
require_once "../../../inclusionfirst_api/Schedules.php";
//$request = $_POST;
$request = file_get_contents("php://input");
$request = json_decode($request, TRUE);
$parameter = Schedules::getAsParameter($request, Schedules::getFields());
$parameter = json_encode($parameter);
$schedules = new Schedules();
$events = $schedules->newSchedule($parameter, $inclusionFirst);
var_dump($events);
 public static function check($field, $value)
 {
     session_start();
     $headers = apache_request_headers();
     $token = $headers['X-Auth-Token'];
     if (!$headers['X-Auth-Token']) {
         header('Invalid CSRF Token', true, 401);
         return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
     } else {
         if ($token != $_SESSION['form_token']) {
             header('Invalid CSRF Token', true, 401);
             return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
         } else {
             $value = strtolower($value);
             $value = preg_replace('/\\s+/', '', $value);
             Schedules::check($field, $value);
         }
     }
 }
Example #13
0
 /**
  * Validate Data on Event Popup Window 
  * @access public
  * @return array results of Validation
  */
 public function validateData()
 {
     $json = '';
     $validate = new Form();
     $date1 = new DateTime($_REQUEST['date'] . ' ' . $_REQUEST['start_time']);
     $date2 = new DateTime($_REQUEST['date'] . ' ' . $_REQUEST['end_time']);
     $error['date'] = $validate->validateDate($date1->format('Y-m-d H:i:s'), $date2->format('Y-m-d H:i:s'));
     if (!$error['date']) {
         $json['date'] = 'Invalid Date';
     }
     $error['description'] = $validate->validateText($_REQUEST['specifics'], 3, 1000);
     if (!$error['description']) {
         $json['description'] = 'Minimum 3 characters maximum 1000 characters';
     }
     $schedules = new Schedules();
     $appointments = $schedules->getAppointmentsByDate($_REQUEST['boardroom_id'], $date1->format('Y-m-d H:i:s'), $date2->format('Y-m-d H:i:s'), $_REQUEST['schedule_id']);
     if ($appointments) {
         $json['appointments'] = $appointments[0];
     }
     if (!$json) {
         if ($appointments = $schedules->updateAppointments($date1->format('Y-m-d H:i:s'), $date2->format('Y-m-d H:i:s'), $_REQUEST)) {
             $json['success'] = "Event changed";
         } else {
             $json['success'] = "Something was broken";
         }
     }
     echo json_encode($json);
     die;
 }