示例#1
0
 public function checkVisitCode($attribute)
 {
     $visit = Visits::model()->find(array('condition' => 'visit_code = ' . $this->{$attribute} . ' '));
     if (empty($visit)) {
         $this->addError($attribute, 'Sorry, this visit code does not exist');
     }
 }
 public function actionStep3($id) {
     if (isFrontUserLoggedIn()) {
         $visit_list = Visits::model()->findAll(array("condition" => " solicitor_id=  '" . $id . "' AND end_date > '" . date('Y-m-d') . "' AND status = 1 "));
         $this->render('step3', array('visit_list' => $visit_list));
     } else {
         $this->redirect(array("/user"));
     }
 }
 public function actionStep3()
 {
     if (isFrontUserLoggedIn()) {
         $visit_code = Yii::app()->session['visit_code'];
         $visit_model = Visits::model()->find(array('condition' => 'visit_code = "' . $visit_code . '" '));
         $step3_model = new Step3();
         if (isset($_POST['Step3'])) {
             $step3_model->attributes = $_POST['Step3'];
             if ($step3_model->validate()) {
                 $donation_model = new Donation();
                 $donation_model->user_id = Yii::app()->session['user_id'];
                 $donation_model->visit_id = $visit_model->id;
                 $donation_model->mobile = '123456789';
                 $donation_model->solicitor_id = $visit_model->solicitor->id;
                 $donation_model->amount = $step3_model->amount;
                 $donation_model->mode = 'web';
                 $donation_model->short_note = $step3_model->message;
                 $donation_model->payment_status = 'pending';
                 $donation_model->reference_number = getToken(8);
                 $donation_model->validate();
                 $donation_model->save();
                 // calculating the debit amount to be inserted in the user_trans table
                 $user_id = Yii::app()->session['user_id'];
                 $user_balance = Users::model()->getUserBalance($user_id);
                 $user_model = Users::model()->findByPk($user_id);
                 $credit_limits = $user_model->credit_limits;
                 $actual_don_amt = $step3_model->amount;
                 //                    if ($actual_don_amt > $user_balance) {
                 //                        // deducting the user credit
                 //                        if ($user_balance > 0) {
                 //                            $from_user_credit = $actual_don_amt - $user_balance;
                 //                        } else {
                 //                            $from_user_credit = $actual_don_amt;
                 //                        }
                 //                        $final_user_credit = $credit_limits - $from_user_credit;
                 //                        $user_model->credit_limits = $final_user_credit;
                 //                        $user_model->validate();
                 //                        $user_model->save();
                 //                    }
                 // for storing in the user_trans table
                 $trans_model = new UserTrans();
                 $trans_model->tran_type = 'DONATION';
                 $trans_model->user_id = $donation_model->user_id;
                 $trans_model->debit = $actual_don_amt;
                 $trans_model->donation_id = $donation_model->id;
                 $trans_model->save();
                 unset(Yii::app()->session['visit_code']);
                 $this->redirect(array("/user/default/accountSummary"));
             }
         }
         $this->render('step3', array('visit_model' => $visit_model, 'step3_model' => $step3_model));
     } else {
         $this->redirect(array("/user"));
     }
 }
示例#4
0
 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $visits = Visits::model()->find(array("condition" => "visit_code = '" . $this->visit_code . "'"));
         if ($visits === null) {
             $this->addError("visit_code", "Visit Code is not correct.");
         } else {
             return true;
         }
     }
 }
示例#5
0
 public function checkVisitCode($attribute)
 {
     $visit = Visits::model()->find(array('condition' => "visit_code = '" . $this->{$attribute} . "'"));
     if (empty($visit)) {
         $this->addError($attribute, 'Sorry, this visit code does not exist');
     } else {
         $visit_end_date = $visit->end_date;
         if ($visit_end_date < date("Y-m-d")) {
             $this->addError($attribute, 'Sorry, you can not donate now as the timeframe for this visit has passed.');
         } else {
             if ($visit->status != 1 || $visit->deleted == 1) {
                 $this->addError($attribute, 'Sorry, you can not donate now as this visit code has been closed.');
             }
         }
     }
 }
示例#6
0
<?php

$visits = new Visits();
$list = $visits->getVisitListFilter($pswd['user'], 'confirmed', 0);
print "<h1>Wizyty</h1><table><form method='GET' action='index.php'><tr><td><input type='checkbox' name='location' value='4' checked /></td><td><select name='param' /><option>Tytuł</option><option>Gospodarz</option><option>Użytkownik</option><option>Data</option><option>Godzina</option></td><td><input type='text' name='value'></td><td><input type='submit' value='Filtruj'></td></tr></form></table><br><table><tr><th>Tytuł:</th><th>Gospodarz:</th><th>Klient:</th><th>Data:</th><th>Godzina:</th></tr>";
if (!empty($list)) {
    foreach ($list as $row) {
        print "<tr><td>{$row['title']}</td><td>{$row['admin']}</td><td>{$row['client']}</td><td>{$row['date']}</td><td>{$row['time']}</td><td><a href='index.php?location=10&id={$row['id']}'>Edytuj</a></td><td><a href='index.php?location=12&id={$row['id']}'>Potwierdź</a></td></tr>";
    }
}
 public function actionProcessPending($id)
 {
     $visit_model = Visits::model()->findByPk($id);
     $attributes = array('payment_status' => 'transferred');
     //Donation::model()->updateAll($attributes, 'payment_status=:payment_status', array(':payment_status' => 'pending'));
     Donation::model()->updateAll($attributes, array('condition' => "payment_status = 'pending' AND visit_id = '{$id}' "));
     $this->redirect(array('donations', 'id' => $visit_model->solicitor_id));
 }
示例#8
0
								'data'=>$model,
								'attributes'=>array(
									array(
							            'label'=>'User',
							            'type'=>'raw',
							            'value'=>Users::model()->findByPk($model->user_id)->username,
							        ),
							        array(
							            'label'=>'Solictor',
							            'type'=>'raw',
							            'value'=>Solicitor::model()->findByPk($model->solicitor_id)->solicitor_code,
							        ),
							        array(
							            'label'=>'Visit',
							            'type'=>'raw',
							            'value'=>Visits::model()->findByPk($model->visit_id)->visit_code,
							        ),
									'mobile',
									'amount',
									'mode',
									'payment_status',
									'reference_number',
								),
							)); ?>
					</div>
				</div>
				<div class="box-footer">
					<?php echo CHtml::link('Back',array('/admin/donation'),array("class" => 'btn btn-info pull-right',"style"=>"margin-left:10px;")); ?>
				</div>
			</div>
		</div>
示例#9
0
文件: surfer.php 项目: rair/yacs
 /**
  * kill the current session
  *
  * This function deletes almost everything related to the current session,
  * except the cookie that contains the session id.
  *
  * @link http://fr.php.net/manual/en/function.session-destroy.php PHP: session_destroy
  */
 public static function reset()
 {
     global $context;
     // if surfer has been authenticated
     if (Surfer::get_id()) {
         // erase presence information in his record
         $query = "UPDATE " . SQL::table_name('users') . " SET click_date='" . NULL_DATE . "', click_anchor=''" . " WHERE id = " . Surfer::get_id();
         SQL::query($query, FALSE, $context['users_connection']);
         // also forget last visits
         include_once $context['path_to_root'] . 'users/visits.php';
         Visits::purge_for_user(Surfer::get_id());
     }
     // unset all of the session variables.
     $_SESSION = array();
     // also delete permanent session cookie, if any
     if (isset($_COOKIE['screening'])) {
         Safe::setcookie('screening', '', time() - 3600, $context['url_to_root']);
         // also clear cookies used in leading index.php
         if ($home = getenv('YACS_HOME')) {
             Safe::setcookie('screening', '', time() - 3600, $home . '/');
         }
         if ($context['url_to_root'] != '/') {
             Safe::setcookie('screening', '', time() - 3600, '/');
         }
     }
     // finally, destroy the session and release related resources --no warning if session data cannot be deleted
     if (session_id() && is_callable('session_destroy')) {
         @session_destroy();
     }
 }
示例#10
0
</section>
<section class="content">
	<div class="row">
		<div class="col-xs-12">
			<div class="box box-info">
				<div class="box-header with-border">
					<h3 class="box-title"><?php 
echo $solicitor->first_name . ' ' . $solicitor->last_name;
?>
 <small><a href="<?php 
echo base_url() . '/admin/donation/update?id=' . $model->id;
?>
">EDIT</a></small></h3>
				</div>
				<div class="box-body">
					<div class="col-xs-12 table-responsive">
						<?php 
$this->widget('zii.widgets.CDetailView', array('htmlOptions' => array("class" => "table table-bordered table-hover dataTable"), 'data' => $model, 'attributes' => array(array('label' => 'User', 'type' => 'raw', 'value' => Users::model()->findByPk($model->user_id)->username), array('label' => 'Solictor', 'type' => 'raw', 'value' => Solicitor::model()->findByPk($model->solicitor_id)->solicitor_code), array('label' => 'Visit', 'type' => 'raw', 'value' => Visits::model()->findByPk($model->visit_id)->visit_code), 'mobile', 'amount', 'mode', 'payment_status', 'reference_number')));
?>
					</div>
				</div>
				<div class="box-footer">
					<?php 
echo CHtml::link('Back', array('/admin/donation'), array("class" => 'btn btn-info pull-right', "style" => "margin-left:10px;"));
?>
				</div>
			</div>
		</div>
	</div>
</section>
 public function gridVisit($data, $row) {
     $code = Visits::model()->findByPk($data->visit_id);
     return $code->visit_code;
 }
示例#12
0
<?php

$param = !empty($_GET['param']) ? $_GET['param'] : NULL;
$value = !empty($_GET['value']) ? $_GET['value'] : NULL;
$visits = new Visits();
if (is_null($param) || is_null($value)) {
    $list = $visits->getVisitList($pswd['user']);
} else {
    $list = $visits->getVisitListFilter($pswd['user'], $param, $value);
}
print "<h1>Wizyty</h1><p>Wizyty na szarym tle nie zostały jeszcze potwierdzone przez gospodarza.</p><table><form method='GET' action='index.php'><tr><td><input type='checkbox' name='location' value='4' checked /></td><td><select name='param' /><option>Tytuł</option><option>Gospodarz</option><option>Użytkownik</option><option>Data</option><option>Godzina</option></td><td><input type='text' name='value'></td><td><input type='submit' value='Filtruj'></td></tr></form></table><br><table><tr><th>Tytuł:</th><th>Gospodarz:</th><th>Klient:</th><th>Data:</th><th>Godzina:</th></tr>";
if (!empty($list)) {
    foreach ($list as $row) {
        if ($row['confirmed'] == 0) {
            print "<tr bgcolor=#999999>";
        } else {
            print "<tr>";
        }
        print "<td>{$row['title']}</td><td>{$row['admin']}</td><td>{$row['client']}</td><td>{$row['date']}</td><td>{$row['time']}</td><td><a href='index.php?location=10&id={$row['id']}'>Edytuj</a></td></tr>";
    }
}
示例#13
0
文件: visit.php 项目: rair/yacs
// get the related anchor, if any
if ($anchor) {
    $anchor = Anchors::get($anchor);
}
// required to format the roster
load_skin('users');
// stop crawlers
if (Surfer::is_crawler()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // an anchor is mandatory
} elseif (!is_object($anchor)) {
    Safe::header('Status: 404 Not Found', TRUE, 404);
    die(i18n::s('No anchor has been found.'));
    // provide updated information for this anchor
} else {
    // silently record this visit
    Visits::track($anchor->get_reference(), $anchor->get_active());
    // return an updated list of current visitors, to be used in AJAX
    $output = Visits::list_users_at_anchor($anchor->get_reference());
    // ensure we are producing some text -- open links in separate pages
    if (is_array($output)) {
        $output =& Skin::build_list($output, 'compact', NULL, TRUE);
    }
    // actual transmission except on a HEAD request
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
        echo $output;
    }
    // the post-processing hook, then exit
    finalize_page(TRUE);
}
示例#14
0
文件: setup.php 项目: rair/yacs
/**
 * dynamically generate the page
 *
 * @see skins/index.php
 */
function send_body()
{
    global $context, $action;
    // check that the user is an admin, but only if there is at least one user record
    $query = "SELECT count(*) FROM " . SQL::table_name('users');
    if (!Surfer::is_associate() && SQL::query($query) !== FALSE) {
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
        echo '<p>' . i18n::s('You are not allowed to perform this operation.') . "</p>\n";
        return;
    }
    // log the current surfer as an associate if not yet the case
    if (!Surfer::is_associate()) {
        $fields = array();
        $fields['id'] = 1;
        $fields['nick_name'] = 'admin';
        $fields['email'] = '';
        $fields['capability'] = 'A';
        Surfer::set($fields);
        echo '<p>' . i18n::s('You have associate privilege') . '</p>';
    }
    // check every table of the database
    if ($action == 'build') {
        // maybe we will have to switch the server off
        $temporary_off = FALSE;
        // ensure nobody else will access the database during the operation
        if (file_exists('../parameters/switch.on')) {
            if (Safe::rename($context['path_to_root'] . 'parameters/switch.on', $context['path_to_root'] . 'parameters/switch.off')) {
                echo BR . i18n::s('The server has been switched off.');
                $temporary_off = TRUE;
            }
            // let concurrent on-going transactions finish properly
            Safe::sleep(3);
            // first installation
        } elseif (!file_exists('../parameters/switch.off')) {
            echo '<p>' . i18n::s('Review provided information and go to the bottom of the page to move forward.') . "</a></p>\n";
        }
        // ensure utf8 character set for this database
        $query = "ALTER DATABASE `" . $context['database'] . "`  DEFAULT CHARACTER SET utf8";
        SQL::query($query);
        // create tables for users
        echo Users::setup();
        // create tables for activities
        echo Activities::setup();
        // create tables for notifications
        include_once '../users/notifications.php';
        echo Notifications::setup();
        // create tables for messages
        echo Mailer::setup();
        // create tables for visits
        include_once '../users/visits.php';
        echo Visits::setup();
        // create tables for sections
        echo Sections::setup();
        // create tables for articles
        echo Articles::setup();
        // create tables for images
        include_once '../images/images.php';
        echo Images::setup();
        // create tables for tables
        include_once '../tables/tables.php';
        echo Tables::setup();
        // create tables for files
        echo Files::setup();
        // create tables for links
        include_once '../links/links.php';
        echo Links::setup();
        // create tables for locations
        include_once '../locations/locations.php';
        echo Locations::setup();
        // create tables for comments
        include_once '../comments/comments.php';
        echo Comments::setup();
        // create tables for categories
        echo Categories::setup();
        // create tables for members
        include_once '../shared/members.php';
        echo Members::setup();
        // create tables for dates
        include_once '../dates/dates.php';
        echo Dates::setup();
        // create tables for servers
        include_once '../servers/servers.php';
        echo Servers::setup();
        // create tables for versions
        include_once '../versions/versions.php';
        echo Versions::setup();
        // create tables for enrolments
        include_once '../shared/enrolments.php';
        echo Enrolments::setup();
        // create tables for values
        include_once '../shared/values.php';
        echo Values::setup();
        // create tables for the cache
        echo Cache::setup();
        // create tables for the php documentation
        include_once '../scripts/phpdoc.php';
        echo PhpDoc::setup();
        // the setup hook
        if (is_callable(array('Hooks', 'include_scripts'))) {
            echo Hooks::include_scripts('control/setup.php');
        }
        // reopen the server for others
        if ($temporary_off && Safe::rename($context['path_to_root'] . 'parameters/switch.off', $context['path_to_root'] . 'parameters/switch.on')) {
            echo '<p>' . i18n::s('The server has been switched on.') . '</p>';
        }
        // in the middle of an update
        if (file_exists('../parameters/switch.off')) {
            echo Skin::build_block('<form method="get" action="../scripts/run_once.php">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Run one-time scripts and go to the Control Panel')) . '</p>' . "\n" . '</form>', 'bottom');
            // this may take several minutes
            echo '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
            // populate the database on first installation
        } elseif (!file_exists('../parameters/switch.on')) {
            echo Skin::build_block('<form method="get" action="populate.php">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Initialize the database')) . '</p>' . "\n" . '</form>', 'bottom');
            // or back to the control panel
        } else {
            $menu = array('control/' => i18n::s('Control Panel'));
            echo Skin::build_list($menu, 'menu_bar');
        }
        // clear the cache
        Cache::clear();
        // remember the change
        $label = i18n::c('The database has been optimised');
        Logger::remember('control/setup.php: ' . $label);
        // ask for confirmation
    } else {
        // the splash message
        echo '<p>' . i18n::s('This script will check the structure of the database and optimize data storage:') . '</p>' . "\n" . '<ul>' . "\n" . '<li>' . i18n::s('Missing tables will be created, if necessary.') . '</li>' . "\n" . '<li>' . i18n::s('Some columns may be created or converted if their type has evolved.') . '</li>' . "\n" . '<li>' . i18n::s('All indexes will be (re)built.') . '</li>' . "\n" . '<li>' . i18n::s('Data files will be optimized as well.') . '</li>' . "\n" . '</ul>' . "\n";
        // the submit button
        echo '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . Skin::build_submit_button(i18n::s('Ensure the database structure is accurate'), NULL, NULL, 'confirmed') . '<input type="hidden" name="action" value="build" />' . '</p></form>';
        // the script used for form handling at the browser
        Page::insert_script('$("#confirmed").focus();');
        // this may take several minutes
        echo '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
    }
}
示例#15
0
<?php

$date = !empty($_POST['date']) ? $_POST['date'] : '';
$day = date('N', strtotime($date));
if ($businessday[$day] != 1) {
    print "<h1>Brak zapisów na ten dzień, wybierz inny.</h1><p><a href='52.html'>Powrót</a></p>";
} else {
    $visit = json_decode($_SESSION['newVisit'], 1);
    $visit['date'] = $date;
    $_SESSION['newVisit'] = json_encode($visit);
    print '<h2>Nowa wizyta</h2><form method="post" action="54.html"><table>';
    if (!empty($date)) {
        $dbvis = new Visits();
        $avaliable = $dbvis->freeAppointments($visit['date'], $visit['host']);
        if ($avaliable == NULL) {
            print "<h1>Brak zapisów na ten dzień, wybierz inny.</h1><p><a href='52.html'>Powrót</a></p>";
        } else {
            print "<tr><td>Tytuł</td><td>{$visit['title']}</td></tr><tr><td>Klient</td><td>{$visit['client']}</td></tr><tr><td>Gospodarz</td><td>{$visit['host']}</td></tr><tr><td>data</td><td>{$visit['date']}</td></tr><tr>\t<td>Godzina: </td>\t<td><select name = 'time'><option>";
            print implode('</option><option>', $avaliable);
            print '</option></td></tr>';
            print '<tr>	<td></td><td><input type = "submit" value = "Umów"/></td></tr></table>';
        }
    }
}
示例#16
0
 /**
  * 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 Visits the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Visits::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#17
0
<?php

$date = date('Y-m-d');
print "\n<script>\n\t\$(document).ready(function() {\n\t\tvar currentLangCode = 'pl';\n\t\t\$('#calendar').fullCalendar({\n\t\t\theader: {\n\t\t\t\tleft: 'prev,next today',\n\t\t\t\tcenter: 'title',\n\t\t\t\tright: 'month,agendaWeek,agendaDay'\n\t\t\t},\n\t\t\tdefaultDate: '{$date}',\n\t\t\tlang: currentLangCode,\n\t\t\tbusinessHours: true,\n\t\t\teventLimit: true,\n\t\t\tevents: ";
$visit = new Visits();
$list = $visit->getJSONlist($pswd['user']);
print $list;
print "\t});\t});</script>\n<div class='calendar' id='calendar'></div>";
	public function visitName($visit_id){
		return Visits::model()->findByPk($visit_id)->visit_code;
	}
示例#19
0
 public function getVisit()
 {
     return $this->hasOne(Visits::className(), ['id' => 'visit_id']);
 }
示例#20
0
文件: view.php 项目: rair/yacs
 if (trim($sections)) {
     $idsurf = Surfer::get_id();
     $label = $item['id'] == $idsurf ? i18n::s('My sections') : i18n::s('Sections');
     $panels[] = array('sections', $label, 'sections_panel', $sections);
 }
 //
 // the information tab
 //
 $information = '';
 // if not at another follow-up page
 if (!$zoom_type) {
     // co-browsing
     if (Surfer::get_id() && Surfer::get_id() != $item['id']) {
         $visited = array();
         // some page or thread has been visited recently
         if ($items = Visits::list_for_user($item['id'])) {
             foreach ($items as $url => $label) {
                 $visited = array_merge($visited, array($url => sprintf(i18n::s('Join %s at %s'), $item['nick_name'], $label)));
             }
             // user is present if active during last 10 minutes (10*60 = 600), but not at some thread
         } elseif (isset($item['click_date']) && $item['click_date'] >= gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600)) {
             // show place of last click
             if (isset($item['click_anchor']) && ($anchor = Anchors::get($item['click_anchor']))) {
                 $visited = array_merge($visited, array($anchor->get_url() => sprintf(i18n::s('Join %s at %s'), $item['nick_name'], $anchor->get_title())));
             }
         }
         // make a box
         if (count($visited)) {
             $information .= Skin::build_box(i18n::s('Co-browsing'), Skin::build_list($visited, 'compact'), 'folded', 'co_browsing');
         }
     }