Example #1
0
 public function __construct($obj_db, $str_member_id)
 {
     // assign simbio database object to property
     $this->obj_db = $obj_db;
     // get member data from database
     $_member_q = $this->obj_db->query("SELECT m.*,mt.* FROM member AS m\n            LEFT JOIN mst_member_type AS mt ON m.member_type_id=mt.member_type_id\n            WHERE member_id='" . $this->obj_db->escape_string($str_member_id) . "'");
     if ($_member_q->num_rows > 0) {
         // set the is_member property flag to TRUE
         $this->is_member = true;
         $_member_d = $_member_q->fetch_assoc();
         // assign database value to class properties
         $this->member_id = $_member_d['member_id'];
         $this->member_name = $_member_d['member_name'];
         $this->member_type_id = $_member_d['member_type_id'];
         $this->member_type_name = $_member_d['member_type_name'];
         $this->register_date = $_member_d['register_date'];
         $this->expire_date = $_member_d['expire_date'];
         $this->member_email = $_member_d['member_email'];
         $this->inst_name = $_member_d['inst_name'];
         $this->member_image = $_member_d['member_image'];
         $this->member_notes = $_member_d['member_notes'];
         $this->is_pending = (bool) $_member_d['is_pending'];
         $this->member_type_prop = array('loan_limit' => $_member_d['loan_limit'], 'loan_periode' => $_member_d['loan_periode'], 'enable_reserve' => $_member_d['enable_reserve'], 'reserve_limit' => $_member_d['reserve_limit'], 'member_periode' => $_member_d['member_periode'], 'reborrow_limit' => $_member_d['reborrow_limit'], 'fine_each_day' => $_member_d['fine_each_day'], 'grace_periode' => $_member_d['grace_periode']);
         // is membership expired ?
         // compare it with current date
         $_current_date = date('Y-m-d');
         $_expired_date = simbio_date::compareDates($_current_date, $_member_d['expire_date']);
         if ($_expired_date <= $_member_d['expire_date']) {
             $this->is_expire = false;
         }
     }
 }
 function showOverdue($obj_db, $array_data)
 {
     $_curr_date = date('Y-m-d');
     if (simbio_date::compareDates($array_data[3], $_curr_date) == $_curr_date) {
         #return '<strong style="color: #f00;">'.$array_data[3].' '.__('OVERDUED').'</strong>';
     } else {
         return $array_data[3];
     }
 }
Example #3
0
 /**
  * Method to check user validity
  *
  * @param   object  $obj_db
  * @return  void
  */
 public function valid($obj_db)
 {
     $_sql_member_login = sprintf("SELECT m.member_id, m.member_name, m.inst_name,\n            m.member_email, m.expire_date, m.register_date, m.is_pending,\n            m.member_type_id, mt.member_type_name\n            FROM member AS m LEFT JOIN mst_member_type AS mt ON m.member_type_id=mt.member_type_id\n            WHERE m.member_id='%s'\n                AND m.mpasswd=MD5('%s')", $obj_db->escape_string(trim($this->username)), $obj_db->escape_string(trim($this->password)));
     $_member_q = $obj_db->query($_sql_member_login);
     // error check
     if ($obj_db->error) {
         echo '<div style="border: 1px dotted #FF0000; color: #FF0000; padding: 5px; margin: 3px;">' . __('Error authenticating user and password to database') . '</div>';
         return false;
     }
     // check if the user exist in database
     if ($_member_q->num_rows < 1) {
         return false;
     } else {
         // fetch data
         $_member_d = $_member_q->fetch_assoc();
         // fill all sessions var
         $_SESSION['mid'] = $_member_d['member_id'];
         $_SESSION['m_name'] = $_member_d['member_name'];
         $_SESSION['m_email'] = $_member_d['member_email'];
         $_SESSION['m_institution'] = $_member_d['inst_name'];
         $_SESSION['m_logintime'] = time();
         $_SESSION['m_expire_date'] = $_member_d['expire_date'];
         $_SESSION['m_member_type_id'] = $_member_d['member_type_id'];
         $_SESSION['m_member_type'] = $_member_d['member_type_name'];
         $_SESSION['m_register_date'] = $_member_d['register_date'];
         $_SESSION['m_membership_pending'] = intval($_member_d['is_pending']) ? true : false;
         $_SESSION['m_is_expired'] = false;
         // check member expiry date
         require_once SIMBIO_BASE_DIR . 'simbio_UTILS/simbio_date.inc.php';
         $_curr_date = date('Y-m-d');
         if (simbio_date::compareDates($_member_d['expire_date'], $_curr_date) == $_curr_date) {
             $_SESSION['m_is_expired'] = true;
         }
         // save md5sum of current application path
         // $_SESSION['checksum'] = md5($_SERVER['SERVER_ADDR'].SENAYAN_BASE_DIR);
         // update the last login time
         $obj_db->query("UPDATE member SET last_login='******',\n                last_login_ip='" . $_SERVER['REMOTE_ADDR'] . "'\n                WHERE member_id='" . $_member_d['member_id'] . "'");
         return true;
     }
     return false;
 }
" frameborder="0" style="width: 100%; height: 500px;"></iframe>
<?php 
} else {
    ob_start();
    $fines_data = array();
    // year
    $selected_year = date('Y');
    if (isset($_GET['year']) and !empty($_GET['year'])) {
        $selected_year = (int) $_GET['year'];
    }
    // month
    $selected_month = date('m');
    if (isset($_GET['month']) and !empty($_GET['month'])) {
        $selected_month = $_GET['month'];
    }
    // query fines data to database
    // echo "SELECT SUBSTRING(`fines_date`, -2) AS `mdate`, SUM(debet) AS `dtotal` FROM `fines` WHERE `fines_date` LIKE '$selected_year-$selected_month%' GROUP BY `fines_date`";
    $_fines_q = $dbs->query("SELECT SUBSTRING(`fines_date`, -2) AS `mdate`, SUM(debet) AS `dtotal` FROM `fines` WHERE `fines_date` LIKE '{$selected_year}-{$selected_month}%' GROUP BY `fines_date`");
    while ($_fines_d = $_fines_q->fetch_row()) {
        $date = (int) preg_replace('@^0+@i', '', $_fines_d[0]);
        $fines_data[$date] = '<div class="data">' . ($_fines_d[1] ? $_fines_d[1] : '0') . '</div>';
    }
    // generate calendar
    $output = simbio_date::generateCalendar($selected_year, $selected_month, $fines_data);
    // print out
    echo '<div class="printPageInfo">Fines Count Report for <strong>' . $months[$selected_month] . ', ' . $selected_year . '</strong> <a class="printReport" onclick="window.print()" href="#">' . __('Print Current Page') . '</a></div>' . "\n";
    echo $output;
    $content = ob_get_clean();
    // include the page template
    require SB . '/admin/' . $sysconf['admin_template']['dir'] . '/printed_page_tpl.php';
}
Example #5
0
 $form->table_content_attr = 'class="alterCell2"';
 // edit mode flag set
 if ($rec_q->num_rows > 0) {
     $form->edit_mode = true;
     // record ID for delete process
     $form->record_id = $itemID;
     // form record title
     $form->record_title = $rec_d['member_name'];
     // submit button attribute
     $form->submit_button_attr = 'name="saveData" value="' . __('Update') . '" class="button"';
 }
 /* Form Element(s) */
 if ($form->edit_mode) {
     // check if member expired
     $curr_date = date('Y-m-d');
     $compared_date = simbio_date::compareDates($rec_d['expire_date'], $curr_date);
     $is_expired = $compared_date == $curr_date;
     $expired_message = '';
     if ($is_expired) {
         // extend membership
         $chbox_array[] = array('1', __('Extend'));
         $form->addCheckBox('extend', __('Extend Membership'), $chbox_array);
         $expired_message = '<b style="color: #FF0000;">(' . __('Membership Already Expired') . ')</b>';
     }
 }
 // member code
 $str_input = simbio_form_element::textField('text', 'memberID', $rec_d['member_id'], 'id="memberID" onblur="ajaxCheckID(\'' . SENAYAN_WEB_ROOT_DIR . 'admin/AJAX_check_id.php\', \'member\', \'member_id\', \'msgBox\', \'memberID\')" style="width: 30%;"');
 $str_input .= ' &nbsp; <span id="msgBox">&nbsp;</span>';
 $form->addAnything(__('Member ID') . '*', $str_input);
 // member name
 $form->addTextField('text', 'memberName', __('Member Name') . '*', $rec_d['member_name'], 'style="width: 100%;"');
Example #6
0
     if ($sql_op->insert('holiday', $data)) {
         utility::jsAlert(__('New Holiday Successfully Saved'));
         // update holiday_dayname session
         $_SESSION['holiday_date'][$data['holiday_date']] = $data['holiday_date'];
         // date range insert
         if (isset($_POST['holDateEnd'])) {
             $holiday_end_date = trim(preg_replace('@\\s[0-9]{2}:[0-9]{2}:[0-9]{2}$@i', '', $_POST['holDateEnd']));
             // check if holiday end date is more than holiday start date
             if (simbio_date::compareDates($holiday_start_date, $holiday_end_date) == $holiday_end_date) {
                 $guard = 365;
                 $d = 1;
                 while ($holiday_start_date != $holiday_end_date) {
                     if ($d == $guard) {
                         break;
                     }
                     $holiday_start_date = simbio_date::getNextDate(1, $holiday_start_date);
                     list($date_year, $date_month, $date_date) = explode('-', $holiday_start_date);
                     $data['holiday_date'] = $holiday_start_date;
                     $data['holiday_dayname'] = date('D', mktime(0, 0, 0, $date_month, $date_date, $date_year));
                     @$sql_op->insert('holiday', $data);
                     $_SESSION['holiday_date'][$holiday_start_date] = $holiday_start_date;
                     $d++;
                 }
             }
         }
         echo '<script type="text/javascript">parent.$(\'#mainContent\').simbioAJAX(\'' . $_SERVER['PHP_SELF'] . '?mode=special\');</script>';
         exit;
     } else {
         utility::jsAlert(__('Holiday FAILED to Save. Please Contact System Administrator') . "\n" . $sql_op->error);
     }
 }
    /**
     * Method to check user validity
     *
     * @param   object  $obj_db
     * @return  void
     */
    public function valid($obj_db) {
        $this->obj_db = $obj_db;
        $_check_login = call_user_func(array($this, $this->auth_method.'Login'));
        // check if the user exist in database
        if (!$_check_login) {
            return false;
        }

        // fill all sessions var
        $_SESSION['mid'] = $this->user_info['member_id'];
        $_SESSION['m_name'] = $this->user_info['member_name'];
        $_SESSION['m_email'] = $this->user_info['member_email'];
        $_SESSION['m_institution'] = $this->user_info['inst_name'];
        $_SESSION['m_logintime'] = time();
        $_SESSION['m_expire_date'] = $this->user_info['expire_date'];
        $_SESSION['m_member_type_id'] = $this->user_info['member_type_id'];
        $_SESSION['m_member_type'] = $this->user_info['member_type_name'];
        $_SESSION['m_register_date'] = $this->user_info['register_date'];
        $_SESSION['m_membership_pending'] = intval($this->user_info['is_pending'])?true:false;
        $_SESSION['m_is_expired'] = false;
        // check member expiry date
        require_once SIMBIO_BASE_DIR.'simbio_UTILS/simbio_date.inc.php';
        $_curr_date = date('Y-m-d');
        if (simbio_date::compareDates($this->user_info['expire_date'], $_curr_date) == $_curr_date) {
            $_SESSION['m_is_expired'] = true;
        }

        // update the last login time
        $obj_db->query("UPDATE member SET last_login='******',
            last_login_ip='".$_SERVER['REMOTE_ADDR']."'
            WHERE member_id='".$this->user_info['member_id']."'");

        return true;
    }
 /**
  * Method to check user validity
  *
  * @param   object  $obj_db
  * @return  void
  */
 public function valid($obj_db)
 {
     global $sysconf;
     $this->obj_db = $obj_db;
     $_check_login = call_user_func(array($this, $this->auth_method . 'Login'));
     // check if the user exist in database
     if (!$_check_login) {
         return false;
     }
     // fill all sessions var
     $_SESSION['mid'] = $this->user_info['member_id'];
     $_SESSION['m_name'] = $this->user_info['member_name'];
     $_SESSION['m_email'] = $this->user_info['member_email'];
     $_SESSION['m_institution'] = $this->user_info['inst_name'];
     $_SESSION['m_logintime'] = time();
     $_SESSION['m_expire_date'] = $this->user_info['expire_date'];
     $_SESSION['m_member_type_id'] = $this->user_info['member_type_id'];
     $_SESSION['m_member_type'] = $this->user_info['member_type_name'];
     $_SESSION['m_register_date'] = $this->user_info['register_date'];
     $_SESSION['m_membership_pending'] = intval($this->user_info['is_pending']) ? true : false;
     $_SESSION['m_is_expired'] = false;
     $_SESSION['m_mark_biblio'] = array();
     $_SESSION['m_can_reserve'] = $this->user_info['enable_reserve'];
     $_SESSION['m_reserve_limit'] = $this->user_info['reserve_limit'];
     // check member expiry date
     require_once SIMBIO . 'simbio_UTILS/simbio_date.inc.php';
     $_curr_date = date('Y-m-d');
     if (simbio_date::compareDates($this->user_info['expire_date'], $_curr_date) == $_curr_date) {
         $_SESSION['m_is_expired'] = true;
     }
     if ($sysconf['chat_system']['enabled'] and $sysconf['chat_system']['opac']) {
         if ($sysconf['chat_system']['vendors'] == 'freichat') {
             $_SESSION['chat_mid'] = mt_rand();
             $chatinfo['userid'] = $_SESSION['chat_mid'];
             $chatinfo['username'] = $_SESSION['m_name'];
             $chat_reg = new simbio_dbop($obj_db);
             $insert = $chat_reg->insert('chat_user', $chatinfo, TRUE);
         }
     }
     // update the last login time
     $obj_db->query("UPDATE member SET last_login='******',\r\n            last_login_ip='" . $_SERVER['REMOTE_ADDR'] . "'\r\n            WHERE member_id='" . $this->user_info['member_id'] . "'");
     return true;
 }
 /**
  * count overdue value
  * @param   integer $int_loan_id
  * @param   string  $str_return_date
  * @return  boolean
  **/
 public function countOverdueValue($int_loan_id, $str_return_date)
 {
     $_on_grace_periode = false;
     // get due date for this loan
     $_loan_q = $this->obj_db->query("SELECT l.due_date, l.loan_rules_id, l.item_code FROM loan AS l WHERE loan_id={$int_loan_id}");
     $_loan_d = $_loan_q->fetch_row();
     // compare dates
     $_date = simbio_date::compareDates($str_return_date, $_loan_d[0]);
     if ($_date == $str_return_date) {
         // how many days the overdue
         $_overdue_days = simbio_date::calcDay($str_return_date, $_loan_d[0]);
         /*
         // count holiday and subtract it from overdue days
         $_holiday_count = simbio_date::countHolidayBetween($_loan_d[0], $str_return_date, $this->holiday_dayname, $this->holiday_date);
         $_overdue_days = $_overdue_days-$_holiday_count;
         */
         if ($_overdue_days < 1) {
             return false;
         }
         // check for grace periode
         if (!empty($this->grace_periode)) {
             $_due_plus_grace_date = simbio_date::getNextDate($this->grace_periode, $_loan_d[0]);
             $_latest_date = simbio_date::compareDates($str_return_date, $_due_plus_grace_date);
             if ($_latest_date == $_due_plus_grace_date) {
                 $_on_grace_periode = true;
             }
         }
         // check for loan rules if any
         if (!empty($_loan_d[1])) {
             $_loan_rules_q = $this->obj_db->query('SELECT fine_each_day, grace_periode FROM mst_loan_rules WHERE loan_rules_id=' . $_loan_d[1]);
             $_loan_rules_d = $_loan_rules_q->fetch_row();
             $this->fine_each_day = $_loan_rules_d[0];
             // check for grace periode
             if (!empty($_loan_rules_d[1])) {
                 $_due_plus_grace_date = simbio_date::getNextDate($_loan_rules_d[1], $_loan_d[0]);
                 $_latest_date = simbio_date::compareDates($str_return_date, $_due_plus_grace_date);
                 if ($_latest_date == $_due_plus_grace_date) {
                     $_on_grace_periode = true;
                 }
             }
         }
         // calculate fines value
         if ($_on_grace_periode) {
             return array('days' => 'On Grace Periode', 'value' => 0, 'item' => $_loan_d[2]);
         } else {
             $_fines_value = $this->fine_each_day * $_overdue_days;
             return array('days' => $_overdue_days, 'value' => $_fines_value, 'item' => $_loan_d[2]);
         }
     }
     return false;
 }
    ?>
" frameborder="0" style="width: 100%; height: 500px;"></iframe>
<?php 
} else {
    ob_start();
    $visitor_data = array();
    // year
    $selected_year = date('Y');
    if (isset($_GET['year']) and !empty($_GET['year'])) {
        $selected_year = (int) $_GET['year'];
    }
    // month
    $selected_month = date('m');
    if (isset($_GET['month']) and !empty($_GET['month'])) {
        $selected_month = $_GET['month'];
    }
    // query visitor data to database
    $_visitor_q = $dbs->query("SELECT SUBSTRING(`checkin_date`, 9, 2) AS `mdate`, COUNT(visitor_id) AS `vtotal` FROM `visitor_count` WHERE `checkin_date` LIKE '{$selected_year}-{$selected_month}%' GROUP BY DATE(`checkin_date`)");
    while ($_visitor_d = $_visitor_q->fetch_row()) {
        $date = (int) preg_replace('@^0+@i', '', $_visitor_d[0]);
        $visitor_data[$date] = '<div class="data">' . ($_visitor_d[1] ? $_visitor_d[1] : '0') . '</div>';
    }
    // generate calendar
    $output = simbio_date::generateCalendar($selected_year, $selected_month, $visitor_data);
    // print out
    echo '<div class="printPageInfo">Visitor Report for year <strong>' . $selected_year . '</strong> <a class="printReport" onclick="window.print()" href="#">[' . __('Print Current Page') . ']</a></div>' . "\n";
    echo $output;
    $content = ob_get_clean();
    // include the page template
    require SENAYAN_BASE_DIR . '/admin/' . $sysconf['admin_template']['dir'] . '/printed_page_tpl.php';
}