public function auto_add_to_cart()
    {
        global $post;
        if (!$this->_core->is_app_mp_page($post)) {
            return false;
        }
        ?>
<script>
(function ($) {

$(document).on("app-confirmation-response_received", function (e, response) {
	if (!(response && response.mp && 1 == response.mp)) return false;
	$(".mp_buy_form").hide().submit();
});

})(jQuery);
</script>
		<?php 
    }
    public function show_settings()
    {
        $services = $this->_core->get_services();
        $replacement = $this->_get_replacement();
        ?>
		<tr valign="top">
			<th scope="row" ><?php 
        _e('Default Service', 'appointments');
        ?>
</th>
			<td colspan="2">
				<select name="default_service">
					<option value=""><?php 
        _e('Default', 'appointments');
        ?>
</option>
				<?php 
        foreach ($services as $service) {
            ?>
					<option value="<?php 
            echo esc_attr($service->ID);
            ?>
" <?php 
            selected($service->ID, $replacement);
            ?>
 >
						<?php 
            echo $service->name;
            ?>
					</option>
				<?php 
        }
        ?>
				</select>
				<span class="description"><?php 
        _e('This is the service that will be used as the default one.', 'appointments');
        ?>
</span>
			</td>
		</tr>
		<?php 
    }
 private function _get_service_capacity($service_id)
 {
     // First, let's hack around the inflexible capacity getter :(
     $old_service = $this->_core->service;
     $this->_core->service = $service_id;
     // We can get the capacity now...
     $capacity = $this->_core->get_capacity();
     // Revert the changes
     $this->_core->service = $old_service;
     // Deal with capacities
     return (int) $capacity;
 }
 public function validate_submitted_fields()
 {
     $fields = !empty($this->_data['additional_fields']) ? $this->_data['additional_fields'] : array();
     if (empty($fields)) {
         return false;
     }
     foreach ($fields as $field) {
         if (empty($field['required'])) {
             continue;
         }
         $name = $this->_to_clean_name($field['label']);
         if (empty($_POST[$name])) {
             $this->_core->json_die($name);
         }
     }
 }
 private function resolve_service_id($worker = false)
 {
     //Try to guess the service ID related to the working hours.
     //This would be accurate only for specific providers providing a single service.
     $services = array();
     if ($worker) {
         $services = appointments_get_worker_services($worker);
     } else {
         $services = $this->_core->get_services();
     }
     foreach ($services as $key => $service) {
         if ($this->_data['service_padding'][$service->ID][self::PADDING_BEFORE] || $this->_data['service_padding'][$service->ID][self::PADDING_AFTER]) {
             return $service->ID;
         }
     }
     return false;
 }
    /**
     * Generate content for app settings
     */
    function screen_content_app_settings()
    {
        // In the future we may use this function without BP too
        if (function_exists('bp_loggedin_user_id')) {
            $user_id = bp_loggedin_user_id();
        } else {
            global $current_user;
            $user_id = $current_user->ID;
        }
        if ($this->_core->is_worker($user_id) && isset($this->_core->options["allow_worker_wh"]) && 'yes' == $this->_core->options["allow_worker_wh"]) {
            // A little trick to pass correct lsw variables to the related function
            $_REQUEST["app_location_id"] = 0;
            $_REQUEST["app_provider_id"] = $user_id;
            $this->_core->get_lsw();
            $result = array();
            $result_open = $this->_core->get_exception($this->_core->location, $this->_core->worker, 'open');
            if ($result_open) {
                $result["open"] = $result_open->days;
            } else {
                $result["open"] = null;
            }
            $result_closed = $this->_core->get_exception($this->_core->location, $this->_core->worker, 'closed');
            if ($result_closed) {
                $result["closed"] = $result_closed->days;
            } else {
                $result["closed"] = null;
            }
            do_action('app_before_bp_app_settings', $user_id);
            ?>
			<div class="standard-form">
				<form method="post">
					<h4><?php 
            _e('My Working Hours', 'appointments');
            ?>
</h4>
					<?php 
            echo $this->_core->working_hour_form('open');
            ?>
					<h4><?php 
            _e('My Break Hours', 'appointments');
            ?>
</h4>
					<?php 
            echo $this->_core->working_hour_form('closed');
            ?>

					<h4><?php 
            _e('My Exceptional Working Days', 'appointments');
            ?>
</h4>

					<input class="datepick" id="open_datepick" type="text" style="width:100%" name="open[exceptional_days]" value="<?php 
            if (isset($result["open"])) {
                echo $result["open"];
            }
            ?>
" />

					<h4><?php 
            _e('My Holidays', 'appointments');
            ?>
</h4>

					<input class="datepick" id="closed_datepick" type="text" style="width:100%" name="closed[exceptional_days]" value="<?php 
            if (isset($result["closed"])) {
                echo $result["closed"];
            }
            ?>
" />


					<div class="submit">
						<input type="submit" name="app_bp_settings_submit" value="<?php 
            _e('Save Changes', 'appointments');
            ?>
" class="auto">
						<input type="hidden" name="app_bp_settings_user" value="<?php 
            echo $user_id;
            ?>
">
						<?php 
            wp_nonce_field('app_bp_settings_submit', 'app_bp_settings_submit');
            ?>
					</div>
				</form>
			</div>

			<?php 
            do_action('app_after_bp_app_settings', $user_id);
        }
    }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Appointments the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Appointments::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 8
0
         if ($appt->saveAppointment()) {
             $resp["content"] = "OK";
             $resp["appId"] = $appt->appId;
         } else {
             $resp["error"] = "Sorry there was a system error. Please try again later.";
         }
     } else {
         $app->getError();
         logit(DEBUG, "Got error in getMessages: uRec: {$app->uRec} ERR: {$app->errorMessageText}");
         $resp["error"] = "ERROR: " . $app->errorMessageText;
     }
     break;
 case $command == "deleteAppt":
     $app->setAuthToken($_POST["authToken"]);
     if ($app->getUrec()) {
         $appt = new Appointments();
         $user = new User();
         $user->getUser($app->uRec);
         $appt->setUser($app->uRec);
         if ($appt->deleteAppointment($_REQUEST["appId"])) {
             $resp["content"] = "OK";
         } else {
             $resp["error"] = "Sorry there was a system error. Please try again later.";
         }
     } else {
         $app->getError();
         logit(DEBUG, "Got error in getMessages: uRec: {$app->uRec} ERR: {$app->errorMessageText}");
         $resp["error"] = "ERROR: " . $app->errorMessageText;
     }
     break;
     //reports
Ejemplo n.º 9
0
<?php

require_once dirname(__FILE__) . './vendor/autoload.php';
//autoload packages
chk_lgn();
$db = new Database();
$user = new User($db->conn);
$appointment = new Appointments($db->conn);
$unum = $user->countAllPatients();
$dnum = $user->countAllDocss();
$anum = $appointment->countAll();
$apps = '';
if ($_SESSION['role'] == 'patient') {
    $apps = $appointment->getApp($_SESSION['user_id']);
}
require 'templates/header.php';
?>


<div id="page-wrapper">

    <div class="container-fluid">

        <!-- Page Heading -->
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">
                    Dashboard
                    <!-- <small>Add doctor</small> -->
                </h1>
                <ol class="breadcrumb">
<?php 
} else {
    ?>

    <p class="flash-message static error"><?php 
    echo e($this->fatalError);
    ?>
</p>
    <p><a href="<?php 
    echo Backend::url('gatto/jobs/qualifications');
    ?>
" class="btn btn-default">Return to Qualifications list</a></p>

<?php 
}
?>





This is a query for the front-end, using Laravel query builder:
it retrieves all the appointments for the logged in customer.

<?php 
$this['appointments'] = Appointments::where('customer_id', '=', Auth::getUser()->id)->where('gatto_jobs_appointments.id', '=', $app_id)->join('gatto_jobs_jobs', 'gatto_jobs_appointments.job_id', '=', 'gatto_jobs_jobs.id')->join('users', 'gatto_jobs_appointments.customer_id', '=', 'users.id')->join('gatto_jobs_timeslots', 'gatto_jobs_timeslots.id', '=', 'time_slot')->get(['gatto_jobs_appointments.*', 'gatto_jobs_jobs.name as name', 'gatto_jobs_timeslots.name as timeslot', 'users.name as username'])->toArray();
?>

This is a simple Eloquent query to find a Job from an ID:
<?php 
$this['selected_job'] = Job::where('id', '=', $this['job_id'])->first()->toArray();
Ejemplo n.º 11
0
    /**
     * Run - called by outside cron
     */
    public static function Run()
    {
        // add here your code...
        // Class::Method();
        $perform_actions = false;
        // update last time running
        $sql = 'SELECT
					cron_type,
					cron_run_last_time,
					cron_run_period,
					cron_run_period_value,
					CASE
						WHEN cron_run_last_time = \'0000-00-00 00:00:00\' THEN \'999\'
						WHEN cron_run_period = \'minute\' THEN TIMESTAMPDIFF(MINUTE, cron_run_last_time, \'' . date('Y-m-d H:i:s') . '\')
						ELSE TIMESTAMPDIFF(HOUR, cron_run_last_time, \'' . date('Y-m-d H:i:s') . '\')
					END as time_diff										
				FROM ' . TABLE_SETTINGS;
        $result = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY);
        if ($result['cron_type'] == 'batch') {
            $perform_actions = true;
        } else {
            if ($result['cron_type'] == 'non-batch' && $result['time_diff'] > $result['cron_run_period_value']) {
                $perform_actions = true;
            } else {
                $perform_actions = false;
            }
        }
        if ($perform_actions) {
            // update Feeds
            RSSFeed::UpdateFeeds();
            if (self::$PROJECT == 'ShoppingCart') {
                // close expired discount campaigns
                Campaigns::UpdateStatus();
                // remove expired orders
                Orders::RemoveExpired();
            } else {
                if (self::$PROJECT == 'HotelSite') {
                    // close expired discount campaigns
                    Campaigns::UpdateStatus();
                    // close expired coupons
                    Coupons::UpdateStatus();
                    // remove expired 'Preparing' bookings
                    Bookings::RemoveExpired();
                } else {
                    if (self::$PROJECT == 'BusinnessDirectory') {
                        // close expired lisitngs
                        Listings::UpdateStatus();
                        // remove old inquiries
                        Inquiries::RemoveOld();
                    } else {
                        if (self::$PROJECT == 'MedicalAppointment') {
                            // remove expired appointments
                            Appointments::RemoveExpired();
                            // send reminders for patient and doctor
                            Appointments::SendReminders();
                        } else {
                            if (self::$PROJECT == 'MicroBlog') {
                                // close expired polls
                                Pools::UpdateStatus();
                            }
                        }
                    }
                }
            }
            // update last time running
            $sql = 'UPDATE ' . TABLE_SETTINGS . ' SET cron_run_last_time = \'' . date('Y-m-d H:i:s') . '\'';
            database_void_query($sql);
        }
    }
Ejemplo n.º 12
0
<?php

require 'vendor/autoload.php';
$db = new Database();
$user = new User($db->conn);
$appointments = new Appointments($db->conn);
$isAvailable = false;
if (!isset($_POST['type'])) {
    echo json_encode(array('valid' => $isAvailable));
    exit;
}
switch ($_POST['type']) {
    case 'email':
        if ($user->check_email($_POST['email'])) {
            $isAvailable = true;
        }
        break;
    case 'phone':
        if ($user->check_phone($_POST['phone'])) {
            $isAvailable = true;
        }
        break;
    case 'delete_user':
        if ($user->delete($_POST['object_id'])) {
            $isAvailable = true;
        }
        break;
    case 'toog_user':
        if ($_POST['status'] == 1) {
            $status = 0;
        } else {
 private function _get_pending_items_count()
 {
     return count($this->_core->get_admin_apps('pending', 0, self::UPPER_LIMIT));
 }