public function getAssociatedUser() { if ($this->_user) { return user::getUser($this->_user); } else { return null; } }
function remove($username = null) { using('lepton.user.*'); if ($username) { if (substr($username, 0, 1) == '#') { $uobj = user::getUser(intval(substr($username, 1))); } else { $uobj = user::find($username); } if (user::remove($uobj)) { console::writeLn("Removed user"); } else { console::writeLn("User not removed, does it exist?"); } } else { console::writeLn("Use: user remove username"); } }
/** * @brief Assign a user to the current session. * * @param $id The user id to assign */ protected function setUser($id) { // Check if the user is active $u = user::getUser($id); if ($u == null) { throw new UserException("Unassociated user id / Integrity failure", UserException::ERR_USER_UNASSOCIATED); } if (!$u->active) { throw new UserException("User is not active, check audit log", UserException::ERR_USER_INACTIVE); } // TODO: Assign to session if (ModuleManager::has('lepton.mvc.session')) { session::set(User::KEY_USER_AUTH, $id); } if (class_exists('request')) { $db = new DatabaseConnection(); $db->updateRow("UPDATE users SET lastlogin=NOW(), lastip=%s WHERE id=%d", request::getRemoteIp(), $id); } if (class_exists('UserEvents')) { event::invoke(UserEvents::EVENT_USER_LOGIN, array('id' => $id)); } }
} unset($_POST['oldpassword']); $arrData['user_id'] = $_POST['user_id']; $arrData['birthday'] = $_POST['birthday']; $arrData['sex'] = $_POST['sex']; $arrData['user_group'] = $_POST['user_group']; unset($_POST); $objWebInit->saveInfo($arrData, 1, false); check::AlertExit('修改成功!', $arrGWeb['WEB_ROOT_pre'] . '/mcenter/admin/'); } if ($_GET['action'] == 'edit') { $userid = intval($_GET['id']); if (empty($userid)) { check::AlertExit("Submit Error!(userid empty)", 1); } $arrUserinfo = $objWebInit->getUser($userid, '*', '', false); //mcenter,user两张表共有信息已mcenter为准 $strWhere = ' WHERE user_id =' . $userid; $field = 'user_name,password,real_name'; $arrMcInfo = check::getAPI('mcenter', 'getUserWhere', "{$strWhere}^{$field}"); $arrUserinfo = array_merge($arrUserinfo, $arrMcInfo); $arrTemp = array(); foreach ($arrGMeta as $k => $v) { if ($k != 'index') { $arrTemp[$k] = $v['name']; } } //生日转换:年-月-日 $arrBDTemp = explode('-', $arrUserinfo['birthday']); $arrUserinfo['year'] = $arrBDTemp[0]; $arrUserinfo['month'] = $arrBDTemp[1];
<?php /** * 用户登录信息文件 * * @author Arthur(ArthurXF@gmail.com) * @copyright (c) 2006 by bizeway.com * @version $Id$ * @package ArthurXF * @subpackage user */ if (is_object($objWebInit) && !empty($_SESSION['user_id'])) { include_once __WEB_ROOT . "/user/class/user.class.php"; $objuser = new user(); $objuser->arrGPdoDB = $objWebInit->arrGPdoDB; $objuser->db(); $arrUserInfo = $objuser->getUser("user_id='" . $_SESSION['user_id'] . "'"); $arrUserInfo = array_pop($arrUserInfo); //全站公用block @(include '../_block.php'); // 输出到模板 $arrMOutput["smarty_assign"]['modifyTrade'] = $_SESSION['user_grade'] < ADVANCE_USER ? 0 : 1; $arrMOutput["smarty_assign"]['arrUserInfo'] = $arrUserInfo; }
function get_form_html($form_id, $id) { ob_start(); ?> <style> .field_name{ width: 20%; } .field input{ width: 100%; margin-left: 0px; } .field .parent{ padding: 0px 0px; } .field select{ width: 100%; } </style> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto;display: none; text-align: center; "> </div> <?php $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $user_type = new user_type(); $user_type->id = $user->user_type_id; $user_type->getUserType(); ?> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <form action="#" method="post" class="action_form" operation="update" style="width:100%;" > <table style="width:100%;"> <tr> <td class="field_name"> <font>USER NAME</font> </td> <td class="field"> <div class="parent"> <input value="<?php echo $user->user_name; ?> " type="text" id="user_name" disabled="disabled" /> </div> </td> </tr> <tr> <td class="field_name"> <font>USER TYPE</font> </td> <td class="field"> <div class="parent"> <input value="<?php echo $user_type->user_type_name; ?> " type="text" id="user_type" disabled="disabled" /> </div> </td> </tr> <tr> <td class="field_name"> <font>PASSWORD </font> </td> <td class="field"> <div class="parent"> <input value="" type="password" id="password_field" required autocomplete="off" /> </div> </td> </tr> <tr> <td class="field_name"> <font>RE-ENTER PASSWORD </font> </td> <td class="field"> <div class="parent"> <input value="" type="password" id="password_copy" required autocomplete="off" /> </div> </td> </tr> <tr></tr> <tr> <td></td> <td> <div style="padding: 0px 12px;"> <div style="width: 100%; margin-left: -12px; padding: 12px; background-color: #0d92bb; border-radius: 5px; float: left;"> <div style="width: 50%; float: right; "> <input style="width: 100%;" type="submit" value="UPDATE" /> </div> <div style="width: 50%;"> <input style="width: 100%;" type="reset" value="CANCEL" /> </div> </div> </div> </td> </tr> </table> </form> </div> <script type="text/javascript"> function setFormActionListener(){ $('form.action_form').on('submit', function(e) { e.preventDefault(); var id = 39; var operation = $(this).attr('operation'); if (operation == 'update') { var password_str = $('form input#password_field').val(); var password_copy = $('form input#password_copy').val(); if(password_str === password_copy){ var data = { form_id: id, password:password_str } update_form_data(data, function(message) { logout(function(){ load_login_page(); }, function(){ load_login_page(); }); alert(message); }, function(message) { alert(message); }); }else{ $('form input#password_field').val(''); $('form input#password_copy').val(''); $('form input#password').focus(); alert("Password and copy not matches !"); } } else { alert("Invalid Operation " + id + ' - ' + operation); } }); }; setFormActionListener(); </script> <?php $form = ob_get_clean(); return $form; }
/** * Функция отправляет пользователю сообщение о том, что его статья удалена * * @param (array) $arrData - массив данных статьи * * @return void */ public function sendUserDeletedArticle(&$arrData) { /** Получаем данные пользователя **/ $user = new user(); if ($uData = $user->getUser("id IN (" . secure::escQuoteData($arrData['id']) . ")")) { $mailer = new mailer(); // массив для замены в шаблоне $mailer->setAddReplace(array('%ARTICLE_TITLE%' => $arrData['title'], '%COMMENTS%' => CONF_MAIL_FORMAT_HTML ? nl2br($arrData['comments']) : $arrData['comments'])); // отправляем письмо администратору $mailer->sendEmail(CONF_MAIL_ADMIN_EMAIL, CONF_SITE_NAME, false, $uData['email'], $uData['first_name'], MAIL_MODERATE_ARTICLES_DELETED . ': ' . $arrData['title'], 'user.article.deleted.txt'); unset($mailer); // уничтожаем объект } unset($user); // уничтожаем объект }
function get_form_html($form_id, $date) { ob_start(); ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> DAY END REPORT OF <input id="date_field" value="<?php if ($date == 0) { $date = date('d/m/Y', time()); } echo $date; ?> " /> </div> <div id="sales_items_table" style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <font>SALES ITEMS</font> <table id="sales_items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7; margin-top: 5px; margin-bottom: 20px;"> <thead style="text-align: center;"> <tr> <td style="width: 5%;"> # </td> <td> ITEM </td> <td style="width: 15%;"> COUNT </td> <td style="width: 15%;"> TOTAL </td> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $grand_total = 0; $total_count = 0; $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $shop = new company(); $shop->id = $user->company_id; $shop->getCompany(); $sale_item = new sales_items(); $date = str_replace('/', '-', $date); $date = date('Y-m-d', strtotime($date)); $sales_items = $sale_item->getOneDaysSaleItems($user->company_id, $date); $i = 0; if ($sales_items == NULL || sizeof($sales_items) == 0) { echo '<tr><td colspan="8"> No Sales Items Found </td></tr>'; } else { foreach ($sales_items as $sales_item) { $grand_total = $grand_total + $sales_item->total; $total_count = $total_count + $sales_item->quantity; ?> <tr> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <?php $item = new item(); $item->id = $sales_item->item_id; $item->getItem(); ?> <td style="text-align: left;"> <?php echo $item->item_name . ' ( ' . $item->item_code . ' )'; ?> </td> <td> <?php echo number_format($sales_item->quantity, 3, '.', ''); ?> </td> <td id="tax"> <?php echo number_format($sales_item->total, 2, '.', ''); ?> </td> </tr> <?php } } ?> <tr> <td></td> <td style="text-align: right;"> TOTAL </td> <td><?php echo number_format($total_count, 3, '.', ''); ?> </td> <td><?php echo number_format($grand_total, 2, '.', ''); ?> </td> </tr> </tbody> </table> <font>STATISTICS</font> <table id="sales_statistics_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7; margin-top: 5px; margin-bottom: 20px;"> <thead style="text-align: center;"> <tr> <td style="width: 5%;"> # </td> <td> STATISTICS </td> <td style="width: 15%;"> COUNT </td> <td style="width: 15%;"> TOTAL TAX </td> <td style="width: 15%;"> TOTAL NET. AMOUNT </td> <td style="width: 15%;"> TOTAL DISCOUNT </td> <td style="width: 15%;"> TOTAL AMOUNT </td> </tr> </thead> <tbody style="text-align: center;"> <tr style="margin-top: 20px;"> <?php $sale = new sales(); $vals = $sale->getOneDaysSaleStatistics($user->company_id, $date); ?> <td>1</td> <td style="text-align: left;">SALES</td> <td><?php echo $vals['count']; ?> </td> <td><?php echo number_format($vals['tax_amount'], 2, '.', ''); ?> </td> <td><?php echo number_format($vals['net_amount'], 2, '.', ''); ?> </td> <td><?php echo number_format($vals['discount'], 2, '.', ''); ?> </td> <td><?php echo number_format($vals['amount'], 2, '.', ''); ?> </td> </tr> </tbody> </table> <font>TAX</font> <table id="sales_statistics_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7; margin-top: 5px;"> <thead style="text-align: center;"> <tr> <td style="width: 5%;"> # </td> <td> TAX(%) </td> <td style="width: 20%;"> COUNT </td> <td style="width: 20%;"> TOTAL TAX </td> </tr> </thead> <tbody style="text-align: center;"> <?php $total_tax = 0; $total_count = 0; $tax_category = new tax_category(); $tax_categories = $tax_category->getTaxCategories(); if (is_array($tax_categories) and count($tax_categories)) { $i = 0; foreach ($tax_categories as $tax_category) { ?> <tr style="margin-top: 20px;"> <?php $tax_vals = $sale->getOneDayTaxDetails($user->company_id, $date, $tax_category->id); ?> <td><?php echo ++$i; ?> </td> <td style="text-align: left; padding-left: 10px;"><?php echo $tax_category->tax_category_name; ?> </td> <td><?php echo number_format($tax_vals['count'], 0, '.', ''); ?> </td> <td><?php echo number_format($tax_vals['tax'], 2, '.', ''); ?> </td> </tr> <?php $total_tax += $tax_vals['tax']; $total_count += $tax_vals['count']; } } ?> <tr style="margin-top: 20px;"> <td></td> <td style="text-align: right; padding-right: 10px;">TOTAL</td> <td><?php echo number_format($total_count, 0, '.', ''); ?> </td> <td><?php echo number_format($total_tax, 2, '.', ''); ?> </td> </tr> </tbody> </table> </div> </div> <script type="text/javascript"> function load_day_end_report(){ var date = $('input#date_field').val(); get_form(24, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }, date); } function on_print_clicked() { var date = $('input#date_field').val(); var header = '<font style="color:#21ACD7; font-size:24px; "><?php echo $shop->company_name . " " . $shop->company_code; ?> </font>' +'<br/><font style="color:#21ACD7; font-size:20px; ">DAY END REPORT OF '+date+'</font>'; $('div#print_container_header') .html(header); var html = $('div#sales_items_table').html(); $('div#print_container_body').html(html); print(); $('div#print_container_header').empty(); $('div#print_container_body').empty(); $('div#print_container_footer').empty(); } function setup_datepicker(){ $('input#date_field').datepick({ minDate:'26/04/2015', dateFormat:'dd/mm/yyyy', maxDate:'0', onSelect:function(){ load_day_end_report(); } }); } setup_datepicker(); </script> <?php $form = ob_get_clean(); return $form; }
function get_form_html($form_id, $id) { ob_start(); ?> <style> .field_name{ width: 20%; } .field input{ width: 100%; margin-left: 0px; } .field .parent{ padding: 0px 0px; } .field select{ width: 100%; } </style> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto;display: none; text-align: center; "> </div> <?php $user = new user(); if ($id != 0) { $user->id = $id; $user->getUser(); } ?> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <form action="#" method="post" class="action_form" operation="add" style="width:100%;" > <table style="width:100%;"> <tr> <td class="field_name"> <font>NAME</font> </td> <td class="field"> <div class="parent"> <input value="<?php echo $user->name; ?> " type="text" id="name" required /> </div> </td> </tr> <tr> <td class="field_name"> <font>SHOP</font> </td> <td class="field"> <div class="parent"> <select id="shop" required <?php if ($id != 0) { echo 'disabled = "disabled"'; } ?> > <option value=""></option> <?php $company = new company(); $companies = $company->getCompanies(); if (is_array($companies) and count($companies) != 0) { foreach ($companies as $company) { echo '<option'; if ($user->company_id === $company->id) { echo ' selected '; } echo ' value="' . $company->id . '"'; echo ' >'; echo $company->company_name . ' - ' . $company->company_code; echo '</option>'; } } //print_r($companies); ?> </select> </div> </td> </tr> <tr> <td class="field_name"> <font>TYPE</font> </td> <td class="field"> <div class="parent"> <select id="type" required ="" <?php if ($id != 0) { echo 'disabled = "disabled"'; } ?> > <option value=""></option> <?php $user_type = new user_type(); $user_types = $user_type->getUserTypes(); if (is_array($user_types) and count($user_types) != 0) { foreach ($user_types as $user_type) { echo '<option'; if ($user->user_type_id === $user_type->id) { echo ' selected '; } echo ' value="' . $user_type->id . '"'; echo ' >'; echo $user_type->user_type_name; echo '</option>'; } } //print_r($companies); ?> </select> </div> </td> </tr> <tr> <td class="field_name"> <font>USER NAME</font> </td> <td class="field"> <div class="parent"> <input value="<?php echo $user->user_name; ?> " type="text" id="username" required /> </div> </td> </tr> <tr> <td class="field_name"> <font>PASSWORD</font> </td> <td class="field"> <div class="parent"> <input type="password" value="" autocomplete="off" id="paswd" <?php if ($id == 0) { echo 'required'; } ?> /> </div> </td> </tr> <tr> <td class="field_name"> <font>RE-ENTER PASSWORD</font> </td> <td class="field"> <div class="parent"> <input type="password" value="" autocomplete="off" id="re_password" <?php if ($id == 0) { echo 'required'; } ?> /> </div> </td> </tr> <tr></tr> <tr> <td></td> <td> <div style="padding: 0px 12px;"> <div style="width: 100%; margin-left: -12px; padding: 12px; background-color: #0d92bb; border-radius: 5px; float: left;"> <div style="width: 50%; float: right; "> <input style="width: 100%;" type="submit" value="ADD" /> </div> <div style="width: 50%;"> <input style="width: 100%;" type="reset" value="CANCEL" /> </div> </div> </div> </td> </tr> </table> </form> </div> <script type="text/javascript"> function setFormActionListener(){ $('form.action_form').on('submit', function(e) { e.preventDefault(); var id = 29; var operation = $(this).attr('operation'); if (operation == 'add') { var paswd = $('form input#paswd').val(); var re_password = $('form input#re_password').val(); if(paswd != re_password){ alert('Both passwords are not matching !'); $('form input#paswd').val(''); $('form input#re_password').val(''); $('form input#paswd').focus(); return; } var data = { form_id: id, name: $('form input#name').val(), username: $('form input#username').val(), shop: $('form select#shop').val(), type: $('form select#type').val(), password: paswd } add_form_data(data, function(message) { load_users_list(); alert(message); }, function(message) { alert(message); }); } else if (operation == 'update') { var user_id = $('form.action_form').attr('user_id'); var paswd = $('form input#paswd').val(); if(paswd !== ''){ var re_password = $('form input#re_password').val(); if(paswd != re_password){ alert('Both passwords are not matching !'); $('form input#paswd').val(''); $('form input#re_password').val(''); $('form input#paswd').focus(); return; } } var data = { form_id: id, user_id: user_id, name: $('form input#name').val(), username: $('form input#username').val(), password: paswd } update_form_data(data, function(message) { load_users_list(); alert(message); }, function(message) { alert(message); }); } else { alert("Invalid Operation " + id + ' - ' + operation); } }); }; setFormActionListener(); </script> <?php $form = ob_get_clean(); return $form; }
$strWhere = "id IN (" . secure::escQuoteData($_POST['paymentData']['user_id']) . ")"; if ($userData = $user->getUser($strWhere)) { $_POST['message'] = nl2br($_POST['message']); $hand->deletePayment($_POST['paymentData']['id'], $userData['email'], $_POST['message']) ? messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, CONF_ADMIN_FILE . '?m=mods&s=payments&action=payments&id=hand' . $filterString) : ($arrErrors[] = db::$message_error); } } elseif ('processing' === $_POST['action'] && !empty($_POST['paymentData']['id']) && !empty($_POST['paymentData']['user_id']) && !empty($_POST['message'])) { $user = new user(); $strWhere = "id IN (" . secure::escQuoteData($_POST['paymentData']['user_id']) . ")"; if ($userData = $user->getUser($strWhere)) { $_POST['message'] = nl2br($_POST['message']); $hand->processingPayment($_POST['paymentData']['id'], $userData['email'], $_POST['message'], $_POST['arrFiles']) ? messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, CONF_ADMIN_FILE . '?m=mods&s=payments&action=payments&id=hand' . $filterString) : ($arrErrors[] = db::$message_error); } } elseif ('close' === $_POST['action'] && !empty($_POST['paymentData']['id']) && !empty($_POST['paymentData']['user_id']) && !empty($_POST['message']) && !empty($_POST['paymentData']['action'])) { $user = new user(); $strWhere = "id IN (" . secure::escQuoteData($_POST['paymentData']['user_id']) . ")"; if ($userData = $user->getUser($strWhere)) { // Собираем массив всех необходимых данных $_POST['message'] = nl2br($_POST['message']); $hand->closePayment($_POST['paymentData'], $userData['email'], $_POST['message']) ? messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, CONF_ADMIN_FILE . '?m=mods&s=payments&action=payments&id=hand' . $filterString) : ($arrErrors[] = db::$message_error); } } } $arrOrderBy = array('datetime' => 'DESC'); $strWhere = "token IN ('active', 'processing')" . $strWhereOrderId; if ($arrHandPayments = $hand->getRecords($strWhere, $arrOrderBy, false, false)) { foreach ($arrHandPayments as $key => $value) { $arrHandPayments[$key]['description'] = $payments->generatePaymentDescription($value['action']); } } $smarty->assignByRef('arrHandPayments', $arrHandPayments); $smarty->assign('paymentsTemplate', SD_ROOT_DIR . 'core/mods/payments/hand/templates/adm.hand.payments.tpl');
$_SESSION['payment'] = array('service' => 'register_' . strtolower($_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type']), 'id' => $_SESSION['sd_user']['data']['id'], 'user_type' => $_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type']); // очищаем куки и сессию пользователя $user->clearUserSessionAndCookie(); messages::messageChangeSaved(MESSAGE_REGISTER_SUCCESS_DO_PAYMENT, MESSAGE_REGISTER_SUCCESS_DO_PAYMENT_TEXT, chpu::createChpuUrl(CONF_SCRIPT_URL . 'index.php?ut=' . $user_type . '&do=payments'), 10000); } else { $smarty->assignByRef('user_email', $_SESSION['sd_user']['data']['email']); $smarty->assign('user_type', $_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type']); // передаем в Smarty права пользователя $smarty->assign('codex', $_SESSION['sd_' . DB_PREFIX . 'codex']); // значения, возвращаемые в форму } } else { // если пользователь не вошел, проверяем его Кукисы и очищаем их, либо делаем автоматический вход if (!isset($_SESSION['sd_user']) && isset($_COOKIE['remid']) && $_COOKIE['remid'] && isset($_COOKIE['remh']) && $_COOKIE['remh']) { // проверяем, есть ли в кукисах наши параметры $arrData = $user->getUser("id IN (" . secure::escQuoteData((int) $_COOKIE['remid']) . ")"); // если пользователь с таким id найден, сверяем хеш if (!empty($arrData)) { // выполняем вход if ($_COOKIE['remh'] === $user->cookieUserHash($arrData)) { $user->authorizeUser($arrData['email'], $arrData['password'], false, true); die('<script type="text/javascript">window.location="' . chpu::createChpuUrl(CONF_SCRIPT_URL . 'index.php?ut=' . $_SESSION['sd_user'][DB_PREFIX . 'conf']['user_type']) . '";</script>'); } else { cookies::deleteAccessCookie(); } } else { cookies::deleteAccessCookie(); } } else { cookies::deleteAccessCookie(); }
function get_form_html($form_id, $id, $page, $limit, $adjacents) { ob_start(); $purchace_obj = new purchaces(); $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $count = $purchace_obj->getPurchacesCount($user->company_id); if ($page == 1) { $start = 0; $head_message = "LAST {$limit} PURCHACES"; } else { $start = ($page - 1) * $limit; $head_message = "PURCHACE {$start} TO " . ($start + $limit); } ?> <div id="head_div" style="padding: 10px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; "> <?php echo $head_message; ?> </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td, div#purchace_items th{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <input type="text" id="search" placeholder="Enter Search Key here..." style="width: 100%; margin-left: 0px;" onkeyup="search()" /> <style> img#search{ position: relative; height: 20px; width: 20px; float: right; top: -29px; right: 10px; } </style> <img id="search" src="../ui/images/search.png" onclick="search()" /> <div style="padding: 10px 0; background-color: transparent; border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; "> <?php echo pagination($limit, $adjacents, $count, $page); ?> </div> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr> <th> # </th> <th> ID </th> <th> BILL NO. </th> <th> DATE </th> <th style=""> PURCHACED FROM </th> <th style=""> PURCHACED BY </th> <th> AMOUNT </th> <th style=""> STOCKED </th> <th style=""> </th> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $purchaces = $purchace_obj->getPurchacesDESC($user->company_id, $start, $limit); $i = $start; if ($purchaces == NULL || sizeof($purchaces) == 0) { echo '<tr><td colspan="8"> No Purchace Found </td></tr>'; } else { foreach ($purchaces as $purchace) { ?> <tr id="<?php echo $purchace->id; ?> " onclick="select_row(this)" status="not_selected"> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td> <?php echo $purchace->id; ?> </td> <td id="bill_number" > <?php echo $purchace->bill_number; ?> </td> <?php $date = date('d/m/Y', strtotime($purchace->created_at) + 5.5 * 60 * 60); $time = date('h:m A', strtotime($purchace->created_at) + 5.5 * 60 * 60); ?> <td id="date" date="<?php echo $date; ?> "> <?php echo $date . ' - ' . $time; ?> </td> <?php $vendor = new wendors(); $vendor->id = $purchace->wendor_id; $vendor->getWendor(); ?> <td id="vendor" vendor_address="<?php echo $vendor->contact_address; ?> "><?php echo $vendor->wendor_name; ?> </td> <td> <?php $p_manager = new user(); $p_manager->id = $purchace->purchace_manager_id; $p_manager->getUser(); echo $p_manager->name; ?> </td> <td id="amount"><?php echo $purchace->amount; ?> </td> <td> <?php if ($purchace->stocked) { echo "YES"; } else { echo 'NO'; } ?> </td> <td id="down_button" style="width: 20px;text-align: center; padding: 10px;"> <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer;" onclick="toggle_items_visibility(this)" src="../ui/images/down_arrow.png"/> <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer; display: none;" onclick="toggle_items_visibility(this)" src="../ui/images/up_arrow.png"/> </td> </tr> <tr id="purchace_item" style="display: none;"> <td colspan="8" style="padding:0 0 20px 0;"> <table id="purchace_items" style="border-collapse: collapse; background-color: #c0effd; width: 80%; color: #21ACD7; float: right;"> <thead> <tr> <th> ITEM </th> <th> QUANTITY </th> <th> PURCHACE RATE </th> <th> MRP </th> <th> TOTAL </th> </tr> </thead> <tbody> <?php if (is_array($purchace->getPurchaceItems()) and count($purchace->getPurchaceItems()) > 0) { foreach ($purchace->getPurchaceItems() as $p_item) { ?> <tr> <td id="item_name"><?php $item = new item(); $item->id = $p_item->item_id; $item->getItem(); echo $item->item_name . ' ( ' . $item->item_code . ' )'; ?> </td> <td id="quantity"><?php echo $p_item->quantity; ?> </td> <?php $tax = new tax_category(); $tax->id = $item->tax_category_id; $tax->getTaxCategory(); ?> <td id="rate" tax_rate="<?php echo $tax->tax_percentage; ?> "><?php echo $p_item->rate; ?> </td> <td><?php echo $item->mrp; ?> </td> <td> <?php echo $p_item->quantity * $p_item->rate; ?> </td> </tr> <?php } } else { ?> <tr><td colspan="6">No Items found !</td></tr> <?php } ?> </tbody> </table> </td> </tr> <?php } } ?> </tbody> </table> </div> <div style="padding: 10px 0; background-color: transparent; border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; "> <?php echo pagination($limit, $adjacents, $count, $page); ?> </div> </div> <script type="text/javascript"> function toggle_items_visibility(down_button) { var row = $(down_button).closest('tr'); row.next('tr').fadeToggle(); row.find('img#toggle_button').toggle(); } function select_row(row) { var j_row = $(row); if (j_row.attr('status') == 'selected') { $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); $('img#print').css('display', 'none'); $('img#print_fade').css('display', 'block'); $('img#delete').css('display', 'none'); $('img#delete_fade').css('display', 'block'); } else { $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); j_row.attr('status', 'selected'); j_row.css('background-color', '#C0EFFD'); $('img#print').css('display', 'block'); $('img#print_fade').css('display', 'none'); $('img#delete').css('display', 'block'); $('img#delete_fade').css('display', 'none'); } } function on_print_clicked() { var selected_row = $('tr[status="selected"]'); var items_table_rows = selected_row.next('tr#purchace_item').find('table#purchace_items').find('tbody').children(); var items = new Array(); var i = 0; var tax_amount = 0; items_table_rows.each(function() { var item_row = $(this); var item_name = item_row.find('td#item_name').html(); var quantity = item_row.find('td#quantity').html(); var rate = item_row.find('td#rate').html(); var tax_rate = item_row.find('td#rate').attr('tax_rate'); var total = parseFloat(rate) * parseFloat(quantity); total = total.toFixed(2); var tax = (total * tax_rate) / (100); tax_amount = parseFloat(tax_amount) + parseFloat(tax); var item = { item_name: item_name, quantity: quantity, rate: rate, tax: tax, tax_rate: tax_rate, total: total } items[i++] = item; }); tax_amount = tax_amount.toFixed(2); var vendor_name = selected_row.find('td#vendor').html(); var vendor_address = selected_row.find('td#vendor').attr('vendor_address'); var amount = selected_row.find('td#amount').html(); amount = parseFloat(amount).toFixed(2); var id = selected_row.attr('id'); var grand_total = (parseFloat(amount) + parseFloat(tax_amount)); grand_total = grand_total.toFixed(2); var rounded_grand_total = Math.round(grand_total); rounded_grand_total = rounded_grand_total.toFixed(2); var round_off = grand_total - rounded_grand_total; round_off = round_off.toFixed(2); var bill_number = selected_row.find('td#bill_number').html(); var date = selected_row.find('td#date').attr('date'); var data = { id: id, vendor_name: vendor_name, vendor_address: vendor_address, amount: amount, date: date, less_discount: '0.00', tax_amount: tax_amount, grand_total: grand_total, rounded_grand_total: rounded_grand_total, round_off: round_off, bill_number: bill_number, items: items } print_purchace_invoice(data); } function print_purchace_invoice(data) { var html = ''; html = '<font style="font-size:30px;">ROYALE PIKNIK TRADERS LLP</font><br/>' + '<font>29/861, PARAYANCHERI, CALICUT - 673006</font><br/>' + '<font>Tin No. 32110844692 </font><br/>' + '<font>PURCHACE BILL</font><br/><br/>'; $('div#print_container_header').html(html); html = ''; //var d = new Date(); //var date = d.getDate()+"/"+(parseInt(d.getMonth())+parseInt(1))+"/"+d.getFullYear(); html = html + "<div<!-- style=\"padding:10px 0;\"><table style=\"float:right;\">" + "<tr><td>Date</td><td>:</td><td>" + data.date + "</td></tr></table>"; html = html + "<table>" + "<tr><td>Bill No. </td><td>:</td><td>" + data.bill_number/*id*/ + "</td></tr>" + "<tr><td>Name </td><td>:</td><td>" + data.vendor_name + "</td></tr>" + "<tr><td></td><td>:</td><td>" + data.vendor_address + "</td></tr></table></div>"; html = html + "<div style=\"border-top:1px dashed #000; margin:10px auto 0 auto;padding:0 0 10px 0;\"><table style=\"width:100%;\"><tr style=\"border-bottom: 1px dashed #000; border-top: 1px dashed #000;\">" + "<td style=\"width:5%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px;\">SNo</td>" + "<td style=\"width:30%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px;\">COMMODITY</td>" + "<td style=\"width:20%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">SCH/HSN NO</td>" + "<td style=\"width:10%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">RATE OF TAX</td>" + "<td style=\"width:10%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">UNIT PRICE</td>" + "<td style=\"width:10%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">QTY</td>" + "<td style=\"width:15%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">PURCHACE VALUE</td></tr>"; var i = 1; for (var key in data.items) { var item = data.items[key]; html = html + "<tr><td>" + i++ + "</td>" + "<td colspan=\"2\">" + item.item_name + "</td>" + "<td style=\"text-align:center;\">" + item.tax_rate + "</td>" + "<td style=\"text-align:center;\">" + item.rate + "</td>" + "<td style=\"text-align:center;\">" + item.quantity + "</td>" //+"<td style=\"text-align:center;\">" + (parseFloat(item.total) - parseFloat(item.tax)) + "</td>" //+"<td style=\"text-align:center;\">" + item.tax + "</td>" + "<td style=\"text-align:right;\">" + item.total + "</td>" + "</tr>"; } html = html + "</table></div>"; html = html + "<div style=\"border-top:1px dashed #000; padding:10px 0;\"><table style=\"margin-left: auto;\">"; html = html + "<tr><td>Amount</td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\">" + data.amount + "</td></tr>"; html = html + "<tr><td>Less Discount</td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\">" + data.less_discount + "</td></tr>"; html = html + "<tr><td>VAT</td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\">" + data.tax_amount + "</td></tr>"; html = html + "<tr><td>Round off</td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\">" + data.round_off + "</td></tr>"; html = html + "<tr style=\"font-size:18px;\"><td><b>GRAND TOTAL</b></td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\"><b>" + data.rounded_grand_total + "</b></td></tr>"; html = html + "</table></div>"; // console.log("Creating bill : " + html); $('div#print_container_body').html(html); html = ''; html = '<div style="width:100%;border-bottom:1px dashed #000;text-align:left;"><font>Rupees: ' + toWords(parseInt(data.rounded_grand_total)) + ' Only. </font></div>'; $('div#print_container_footer').html(html); print(); $('div#print_container_header').empty(); $('div#print_container_body').empty(); $('div#print_container_footer').empty(); } // American Numbering System var th = ['', 'Thousand', 'Million', 'Billion', 'Trillion']; var dg = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine']; var tn = ['Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen']; var tw = ['Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']; function toWords(s) { s = s.toString(); s = s.replace(/[\, ]/g, ''); if (s != parseFloat(s)) return 'not a number'; var x = s.indexOf('.'); if (x == -1) x = s.length; if (x > 15) return 'too big'; var n = s.split(''); var str = ''; var sk = 0; for (var i = 0; i < x; i++) { if ((x - i) % 3 == 2) { if (n[i] == '1') { str += tn[Number(n[i + 1])] + ' '; i++; sk = 1; } else if (n[i] != 0) { str += tw[n[i] - 2] + ' '; sk = 1; } } else if (n[i] != 0) { str += dg[n[i]] + ' '; if ((x - i) % 3 == 0) str += 'hundred '; sk = 1; } if ((x - i) % 3 == 1) { if (sk) str += th[(x - i - 1) / 3] + ' '; sk = 0; } } if (x != s.length) { var y = s.length; str += 'point '; for (var i = x + 1; i < y; i++) str += dg[n[i]] + ' '; } return str.replace(/\s+/g, ' '); } function search() { var search_key = $('input#search').val(); if (search_key !== '') { console.log("search key " + search_key); searchTable(search_key); } else { $('#items_table tr').show(); $('#items_table tr#purchace_item').hide(); } } function searchTable(inputVal) { var table = $('#items_table'); table.find('tr').each(function(index, row) { if ($(row).attr('id') !== 'purchace_item') { var allCells = $(row).find('td'); if (allCells.length > 0) { var found = false; allCells.each(function(index, td) { var regExp = new RegExp(inputVal, 'i'); if (regExp.test($(td).text())) { found = true; return false; } }); if (found == true) $(row).show(); else $(row).hide(); } var items_row = $(row).next('tr'); var allCells = items_row.find('td'); if (allCells.length > 0) { var found = false; allCells.each(function(index, td) { var regExp = new RegExp(inputVal, 'i'); if (regExp.test($(td).text())) { found = true; return false; } }); if (found == true) { $(row).show(); items_row.show(); } else { items_row.hide(); } } } }); } function on_delete_clicked() { var selected_row = $('tr[status="selected"]'); var id = selected_row.attr('id'); if (confirm('Are you sure you want to delete PURCHACE-' + id + ' ?')) { var data = { form_id: 19, purchace_id: id } delete_form_data(data, function(message) { get_form(19, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }); alert(message); }, function(message) { alert(message); }); } } function set_pagination_listener(){ $('.pagination').on('click','.page-numbers',function(e){ e.preventDefault(); var page = $(this).attr('page'); var id = 0; get_form(19, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); alert(message); },id ,page ); return false; }); } set_pagination_listener(); </script> <?php $form = ob_get_clean(); return $form; }
/** * private функция рассылки почтовых сообщений при модерации новости * * @param (string) $action - действие, которое было выполнено с новостью * @param (array) $arrData - должен содержать id пользователя и title новости * @param (string or false) $comments - комментарий к модерируемой новости * @param (string or false) $date - дата, когда новость будет автоматически удалена. По умолчанию false * * @return void */ private function moderateSendMail($action, $arrData, $comments, $date = false) { // проверяем, есть ли данные по новости if (!$arrData['id_user'] || !$arrData['title']) { return false; } $user = new user(); // получаем емайл пользователя if (!($arrUser = $user->getUser("id IN (" . secure::escQuoteData($arrData['id_user']) . ")"))) { return false; } // проверяем действие, выполненное над новостью switch ($action) { case 'show': $status = MAIL_MODERATE_NEWS_ACTIVATED; break; case 'correction': $status = MAIL_MODERATE_NEWS_CORRECTION; break; case 'del': $status = MAIL_MODERATE_NEWS_DELETED; break; } $mailer = new mailer(); // массив для замены в шаблоне $mailer->setAddReplace(array('%TITLE%' => $arrData['title'], '%STATUS%' => $status, '%COMMENTS%' => $comments ? $comments : MAIL_MODERATE_NEWS_COMMENTS, '%DELDATE%' => $date ? MAIL_MODERATE_NEWS_DELETE_DATE . date(terms::dateFormatFromSmarty(CONF_DATE_FORMAT, CONF_TIME_FORMAT), strtotime($date)) : '')); $mailer->sendEmail(CONF_MAIL_ADMIN_EMAIL, false, false, $arrUser['email'], $arrUser['email'], MAIL_SUBJ_MODERATE_NEWS . ': ' . $arrData['title'], 'moderate.news.txt'); }
function get_form_html($form_id, $id, $page, $limit, $adjacents) { ob_start(); $sale_obj = new sales(); $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $count = $sale_obj->getLastThreeDaysSalesCount($user->company_id); if ($page == 1) { $start = 0; $head_message = "LAST {$limit} SALES OF LAST 3 DAYS"; } else { $start = ($page - 1) * $limit; $head_message = "SALES {$start} TO " . ($start + $limit) . " SALES OF LAST 3 DAYS"; } ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> <?php echo $head_message; ?> </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td,div#purchace_items th{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <input type="text" id="search" placeholder="Enter Search Key here..." style="width: 100%; margin-left: 0px;" onkeyup="search()" /> <style> img#search{ position: relative; height: 20px; width: 20px; float: right; top: -29px; right: 10px; } </style> <img id="search" src="../ui/images/search.png" onclick="search()" /> <div style="padding: 10px 0; background-color: transparent; border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; "> <?php echo pagination($limit, $adjacents, $count, $page); ?> </div> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr status="not_selected" > <th> # </th> <th> ID </th> <th> DATE & TIME </th> <th> CUSTOMER </th> <th style=""> DISCOUNT </th> <th style=""> TAX </th> <th style=""> NET. AMOUNT </th> <th style=""> TOTAL </th> <th style=""> </th> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $sales = $sale_obj->getLastThreeDaysSales($user->company_id, $start, $limit); $i = $start; if ($sales == NULL || sizeof($sales) == 0) { echo '<tr><td colspan="8"> No Sales Found </td></tr>'; } else { foreach ($sales as $sale) { ?> <tr id="<?php echo $sale->id; ?> " onclick="select_row(this)" status="not_selected" > <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td> <?php echo $sale->id; ?> </td> <?php $date = date('d/m/Y', strtotime($sale->sale_at) + 5.5 * 60 * 60); $time = date('h:m A', strtotime($sale->sale_at) + 5.5 * 60 * 60); ?> <td id="date" date="<?php echo $date; ?> " time="<?php echo $time; ?> "> <?php echo $date . ' - ' . $time; ?> </td> <?php $customer = new customer(); $customer->id = $sale->customer_id; $customer->getCustomer(); ?> <td id="customer" c_name="<?php echo $customer->customer_name; ?> " c_id="<?php echo $customer->id; ?> " > <?php echo $customer->customer_name . ' ( ID : ' . $customer->id . ' )'; ?> </td> <td id="discount"> <?php echo number_format($sale->discount, 2, '.', ''); ?> </td> <td id="tax"> <?php echo number_format($sale->tax_amount, 2, '.', ''); ?> </td> <td id="net_amount"> <?php echo number_format($sale->net_amount, 2, '.', ''); ?> </td> <td id="total"> <?php echo number_format($sale->amount, 2, '.', ''); ?> </td> <td id="down_button" style="width: 20px;text-align: center; padding: 10px;"> <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer;" onclick="toggle_items_visibility(this)" src="../ui/images/down_arrow.png"/> <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer; display: none;" onclick="toggle_items_visibility(this)" src="../ui/images/up_arrow.png"/> </td> </tr> <tr style="display: none;" id="sale_items"> <td colspan="8" style="padding:0 0 20px 0;"> <table id="sale_items" style="border-collapse: collapse; background-color: #c0effd; width: 80%; color: #21ACD7; float: right;"> <thead> <tr> <th> ITEM </th> <th> QUANTITY </th> <th> RATE </th> <th> NET. AMOUNT </th> <th> DISCOUNT </th> <th> TAX </th> <th> TOTAL </th> </tr> </thead> <tbody> <?php if (is_array($sale->getSalesItems()) and count($sale->getSalesItems())) { foreach ($sale->getSalesItems() as $s_item) { ?> <tr id="<?php echo $s_item->id; ?> "> <?php $item = new item(); $item->id = $s_item->item_id; $item->getItem(); ?> <td id="item" item_name="<?php echo $item->item_name . ' - ' . $item->item_code; ?> " item_id="<?php echo $item->id; ?> "> <?php echo $item->item_name . ' - ' . $item->item_code; ?> </td> <td id="quantity" val="<?php echo $s_item->quantity; ?> "> <?php echo number_format($s_item->quantity, 3, '.', ''); ?> </td> <td id="rate" val="<?php echo $s_item->rate; ?> "> <?php echo number_format($s_item->rate, 2, '.', ''); ?> </td> <?php $tax_category = new tax_category(); $tax_category->id = $item->tax_category_id; $tax_category->getTaxCategory(); $total = $s_item->quantity * $s_item->rate; if ($total == 0) { $discount_percent = 0; } else { $discount_percent = $s_item->discount * 100 / $total; } $total = $total - $s_item->discount; ?> <td> <?php echo number_format($total - $s_item->tax, 2, '.', ''); ?> </td> <td id="discount" val="<?php echo $s_item->discount; ?> " discount_percent="<?php echo $discount_percent; ?> "> <?php echo number_format($s_item->discount, 2, '.', ''); ?> </td> <td id="tax" val="<?php echo $s_item->tax; ?> " tax_rate="<?php echo $tax_category->tax_percentage; ?> "> <?php echo number_format($s_item->tax, 2, '.', ''); ?> </td> <td id="total" val="<?php echo $total; ?> "> <?php echo number_format($total, 2, '.', ''); ?> </td> </tr> <?php } } else { echo '<tr><td colspan="7">No item found</td></tr>'; } ?> </tbody> </table> </td> </tr> <?php } } ?> </tbody> </table> </div> <div style="padding: 10px 0; background-color: transparent; border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; "> <?php echo pagination($limit, $adjacents, $count, $page); ?> </div> </div> <script type="text/javascript"> function on_edit_clicked(){ var selected_row = $('tr[status="selected"]'); var sale_items_table = selected_row.next('tr').find('table#sale_items'); var sale_items = sale_items_table.find('tbody').children(); var items = new Array(); var i = 0; sale_items.each(function() { var item_name = $(this).find('td#item').attr('item_name'); var item_id = $(this).find('td#item').attr('item_id'); var id = $(this).attr('id'); var quantity = $(this).find('td#quantity').attr('val'); quantity = parseFloat(quantity).toFixed(3); var rate = $(this).find('td#rate').attr('val'); rate = parseFloat(rate).toFixed(2); var tax = $(this).find('td#tax').attr('val'); var tax_rate = $(this).find('td#tax').attr('tax_rate'); var discount = $(this).find('td#discount').attr('val'); var discount_percent = $(this).find('td#discount').attr('discount_percent'); var total = $(this).find('td#total').attr('val'); var item = { id: id, quantity: quantity, rate: rate, item_name: item_name, item_id: item_id, total: total, discount:discount, discount_percent:discount_percent, tax_rate: tax_rate, tax: tax } items[i++] = item; }); var c_name = selected_row.find('td#customer').attr('c_name'); var c_id = selected_row.find('td#customer').attr('c_id'); var sale_id = selected_row.attr('id'); var total = selected_row.find('td#total').html(); total = parseFloat(total).toFixed(2); var total_tax = selected_row.find('td#tax').html(); var total_discount = selected_row.find('td#discount').html(); var date = selected_row.find('td#date').attr('date'); var time = selected_row.find('td#date').attr('time'); var net_total = selected_row.find('td#net_amount').html(); get_form(2, ///sales return invoice function (html, tools){ $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); $('input#sale_id').val(sale_id); var form = $('div#form-body').find('form.action_form'); form.attr('operation', 'update'); form.find('input#customer_id').val(c_name+' ( ID : '+c_id+' )'); form.find('input#customer_id').attr('disabled', 'true'); form.find('input#date_and_time').val(date + ' - ' + time); form.find('input#date_and_time').attr('date', date); form.find('input#date_and_time').attr('time', time); $('table#items_table tbody').empty(); for(var i = 0; i<items.length; i++){ add_sale_item(); var row = $('table#items_table tbody tr:last-child'); var item = items[i]; row.find('input#item').attr('disabled', 'disabled'); row.find('input#item').val(item.item_name); row.find('input#item').attr('item_id', item.item_id); row.find('input#quantity').val(item.quantity); row.find('input#quantity').attr('max', item.quantity); row.find('input#rate').val(item.rate); row.find('input#rate').attr('tax', item.tax_rate); row.find('input#discount_percent').val(item.discount_percent); row.find('input#total').val(item.total); row.find('input#total').attr('tax', item.tax); row.find('input#total').attr('discount', item.discount); row.find('input#discount').val(item.discount); row.attr('previous', true); } form.find('span#total').html(total); form.find('span#total').attr('tax', total_tax); form.find('span#total').attr('discount', total_discount); form.find('span#total_paid').html(total); form.find('span#balance').html('0.00'); form.attr('sale_id', sale_id); form.attr('customer_name', c_name); form.attr('customer_id', c_id); }, function (message){ $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); } ); } function on_print_clicked() { var selected_row = $('tr[status="selected"]'); var sale_items_table = selected_row.next('tr').find('table#sale_items'); var sale_items = sale_items_table.find('tbody').children(); var items = new Array(); var i = 0; sale_items.each(function() { var item_name = $(this).find('td#item').attr('item_name'); var id = $(this).attr('id'); var quantity = $(this).find('td#quantity').attr('val'); var rate = $(this).find('td#rate').attr('val'); var tax = $(this).find('td#tax').attr('val'); var tax_rate = $(this).find('td#tax').attr('tax_rate'); var discount = $(this).find('td#discount').attr('val'); var total = $(this).find('td#total').attr('val'); total = parseFloat(total); total = total.toFixed(2); var item = { id: id, quantity: quantity, rate: rate, item_name: item_name, total: total, discount:discount, tax: tax, tax_rate: tax_rate } items[i++] = item; }); var c_name = selected_row.find('td#customer').attr('c_name'); var c_id = selected_row.find('td#customer').attr('c_id'); if(c_id == 0){ c_name = 'Not Regd.'; } var sale_id = selected_row.attr('id'); var total = selected_row.find('td#total').html(); total = parseFloat(total); total = total.toFixed(2); var total_tax = selected_row.find('td#tax').html(); total_tax = parseFloat(total_tax); total_tax = total_tax.toFixed(2); var total_discount = selected_row.find('td#discount').html(); total_discount = parseFloat(total_discount); total_discount = total_discount.toFixed(2); var net_total = selected_row.find('td#net_amount').html(); net_total = parseFloat(net_total); net_total = net_total.toFixed(2); var date = selected_row.find('td#date').attr('date'); var time = selected_row.find('td#date').attr('time'); var data = { customer_id: c_id, total: total, net_amount: net_total, tax_amount: total_tax, discount:total_discount, items: items, date: date, time: time } print_bill(data, c_name, sale_id); } function print_bill(data, customer_name, sale_id) { var html = ''; html ='<img id="logo_bill" src="images/nutiez.png"/><br/><font id="print_container_header_company_adderss">Royal Piknik Traders LLP, 29/861</font>' +'<br/><font id="print_container_header_company_adderss">Parayancheri, Calicut</font><br/><font id="print_container_header_company_adderss">' +'Phone : 0495 2741095,+91 9388627725</font><br/><font id="print_container_header_company_adderss">The kerala value added tax rules 2005/ form no. 8</font>' +'<br/><font id="print_container_header_company_adderss">Tin : 32110844692</font>' +'<br/><font id="print_container_header_company_adderss">True Copy</font>'; $('div#print_container_header').html(html); html = ''; html = html + "<div<!-- style=\"padding:10px 0;\"><table style=\"float:right; font-size: 12px;\">" +"<tr><td>Date</td><td>:</td><td style=\"text-align:right;\">" + data.date + "</td></tr>" +"<tr><td>Time</td><td>:</td><td style=\"text-align:right;\">" + data.time + "</td></tr></table>"; html = html + "<table style=\"font-size: 12px;\">" +"<tr><td>Bill No.</td><td>:</td><td>" + sale_id + "</td></tr>" +"<tr><td>Cust. ID</td><td>:</td><td>" + data.customer_id + "</td></tr>" +"<tr><td>Cust. Name</td><td>:</td><td>" + customer_name + "</td></tr></table></div>"; html = html + "<div style=\"border-top:1px dashed #000; margin:10px auto 0 auto;padding:0 0 10px 0;\">" + "<table style=\"width:100%;font-size: 12px;\"><tr style=\"border-bottom: 1px solid #000; border-top: 1px solid #000;\">" + "<td style=\"width:44%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px;\">Description</td>" + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Qty</td>" + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Rate</td>" // + "<td style=\"width:15%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Amount</td>" // + "<td style=\"width:10%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Tax</td>" + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Tax(%)</td>" + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Total</td></tr>"; var i = 0; for (var key in data.items) { var item = data.items[key]; html = html + "<tr><td>" + item.item_name + "</td>" +"<td style=\"text-align:right;\">" + parseFloat(item.quantity).toFixed(3) + "</td>" +"<td style=\"text-align:right;\">" + parseFloat(item.rate).toFixed(2) + "</td>" //+"<td style=\"text-align:right;\">" + (parseFloat(item.total) - parseFloat(item.tax)) + "</td>" // +"<td style=\"text-align:right;\">" + item.tax + "</td>" +"<td style=\"text-align:right;\">" + item.tax_rate + "</td>" +"<td style=\"text-align:right;\">" + parseFloat(item.total).toFixed(2) + "</td>" +"</tr>"; } html = html + "</table></div>"; html = html + "<div style=\"border-top:1px dashed #000; padding:10px 0;\"><table style=\"margin-left: auto;font-size: 12px;\">"; html = html + "<tr><td>Net. Amount</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.net_amount + "</td></tr>"; if(parseFloat(data.discount) > 0 ){ html = html + "<tr><td>Discount</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.discount + "</td></tr>"; } html = html + "<tr><td>Tax</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.tax_amount + "</td></tr>"; html = html + "<tr style=\"font-size:18px;\"><td><b>Total</b></td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\"><b>" + data.total + "</b></td></tr>"; html = html + "</table></div>"; // console.log("Creating bill : " + html); $('div#print_container_body').html(html); html = ''; html = '<font>Thank you for shoping</font><br/><font>Visit again...</font> '; $('div#print_container_footer').html(html); print(); $('div#print_container_header').empty(); $('div#print_container_body').empty(); $('div#print_container_footer').empty(); } function select_row(row) { var j_row = $(row); if(j_row.attr('status') == 'selected'){ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); $('img#edit').css('display', 'none'); $('img#edit_fade').css('display', 'block'); $('img#print').css('display', 'none'); $('img#print_fade').css('display', 'block'); }else{ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); j_row.attr('status', 'selected'); j_row.css('background-color', '#C0EFFD'); $('img#edit').css('display', 'block'); $('img#edit_fade').css('display', 'none'); $('img#print').css('display', 'block'); $('img#print_fade').css('display', 'none'); } } function toggle_items_visibility(down_button) { var row = $(down_button).closest('tr'); row.next('tr').fadeToggle(); row.find('img#toggle_button').toggle(); } function search(){ var search_key = $('input#search').val(); if(search_key !== ''){ console.log("search key "+ search_key); searchTable(search_key); }else{ $('#items_table tr').show(); $('#items_table tr#sale_items').hide(); } } function searchTable(inputVal) { var table = $('#items_table'); table.find('tr').each(function(index, row) { if($(row).attr('id')!=='sale_items'){ var allCells = $(row).find('td'); if(allCells.length > 0) { var found = false; allCells.each(function(index, td) { var regExp = new RegExp(inputVal, 'i'); if(regExp.test($(td).text())) { found = true; return false; } }); if(found == true)$(row).show();else $(row).hide(); } var items_row = $(row).next('tr'); var allCells = items_row.find('td'); if(allCells.length > 0) { var found = false; allCells.each(function(index, td) { var regExp = new RegExp(inputVal, 'i'); if(regExp.test($(td).text())) { found = true; return false; } }); if(found == true){ $(row).show(); items_row.show(); }else{ items_row.hide(); } } } }); } function set_pagination_listener(){ $('.pagination').on('click','.page-numbers',function(e){ e.preventDefault(); var page = $(this).attr('page'); var id = 0; get_form(3, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); alert(message); },id ,page ); return false; }); } set_pagination_listener(); </script> <?php $form = ob_get_clean(); return $form; }
function get_form_html($form_id, $date) { ob_start(); ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> MONTHLY REPORT OF <input id="year_field" value="<?php if ($date == 0) { $year = date('Y', time()); } else { $year = split('/', $date)[0]; } echo $year; ?> " onchange="load_monthly_report()" style="width: 55px;" min="2015" max="2065" required /> <select id="month_field" onchange="load_monthly_report()" > <?php if ($date == 0) { $month = date('m', time()); } else { $month = split('/', $date)[1]; } ?> <option <?php if ($month == 1) { echo ' selected '; } ?> value="1">JANUARY</option> <option <?php if ($month == 2) { echo ' selected '; } ?> value="2">FEBRUARY</option> <option <?php if ($month == 3) { echo ' selected '; } ?> value="3">MARCH</option> <option <?php if ($month == 4) { echo ' selected '; } ?> value="4">APRIL</option> <option <?php if ($month == 5) { echo ' selected '; } ?> value="5">MAY</option> <option <?php if ($month == 6) { echo ' selected '; } ?> value="6">JUNE</option> <option <?php if ($month == 7) { echo ' selected '; } ?> value="7">JULY</option> <option <?php if ($month == 8) { echo ' selected '; } ?> value="8">AUGUST</option> <option <?php if ($month == 9) { echo ' selected '; } ?> value="9">SEPTEMBER</option> <option <?php if ($month == 10) { echo ' selected '; } ?> value="10">OCTOBER</option> <option <?php if ($month == 11) { echo ' selected '; } ?> value="11">NOVEMBER</option> <option <?php if ($month == 12) { echo ' selected '; } ?> value="121">DECEMBER</option> </select> </div> <div id="content_table" style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr> <td style="width: 5%;"> # </td> <td> DESCRIPTION </td> <td style="width: 15%;"> INCOME </td> <td style="width: 15%;"> EXPENCE </td> <td style="width: 15%;"> BALANCE </td> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $balance = 0; $income_total = 0; $expence_total = 0; $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $i = 0; if ($year < 2015 || $year > 2065 || $month < 1 || $month > 12) { echo '<tr><td colspan="8"> In Valid Month Found </td></tr>'; } else { //$grand_total = $grand_total + $sales_item->total; ?> <tr> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <?php $sale = new sales(); $vals = $sale->getOneMonthsSaleSummary($user->company_id, $month, $year); ?> <td style="text-align: left;"> Sales </td> <td> <?php echo number_format($vals['amount'], 2, '.', ''); $income_total = $income_total + $vals['amount']; ?> </td> <td> </td> <td id="tax"> <?php $balance = $income_total - $expence_total; echo number_format($balance, 2, '.', ''); ?> </td> </tr> <tr> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td style="text-align: left;"> Tax </td> <td> </td> <td> <?php echo number_format($vals['tax_amount'], 2, '.', ''); $expence_total = $expence_total + $vals['tax_amount']; ?> </td> <td id="tax"> <?php $balance = $income_total - $expence_total; echo number_format($balance, 2, '.', ''); ?> </td> </tr> <tr> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <?php $purchace = new purchaces(); $vals = $purchace->getOneMonthsPurchaceSummary($user->company_id, $month, $year); ?> <td style="text-align: left;"> Purchaces </td> <td> </td> <td> <?php echo number_format($vals['amount'], 2, '.', ''); $expence_total = $expence_total + $vals['amount']; ?> </td> <td id="tax"> <?php $balance = $income_total - $expence_total; echo number_format($balance, 2, '.', ''); ?> </td> </tr> <tr> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <?php $expence = new expences(); $vals = $expence->getOneMonthsExpenceSummary($user->company_id, $month, $year); ?> <td style="text-align: left;"> Expences </td> <td> </td> <td> <?php echo number_format($vals['amount'], 2, '.', ''); $expence_total = $expence_total + $vals['amount']; ?> </td> <td id="tax"> <?php $balance = $income_total - $expence_total; echo number_format($balance, 2, '.', ''); ?> </td> </tr> <tr> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <?php $bank_deposit = new bank_deposits(); $vals = $bank_deposit->getOneMonthsBankDepositsSummary($user->company_id, $month, $year); ?> <td style="text-align: left;"> Bank Deposit </td> <td> </td> <td> <?php echo number_format($vals['amount'], 2, '.', ''); $expence_total = $expence_total + $vals['amount']; ?> </td> <td id="tax"> <?php $balance = $income_total - $expence_total; echo number_format($balance, 2, '.', ''); ?> </td> </tr> <?php } ?> <tr> <td></td> <td style="text-align: right;"> TOTAL </td> <td><?php echo number_format($income_total, 2, '.', ''); ?> </td> <td><?php echo number_format($expence_total, 2, '.', ''); ?> </td> <td><?php echo number_format($balance, 2, '.', ''); ?> </td> </tr> </tbody> </table> <?php /* ?> <table id="sales_statistics_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7; margin-top: 20px;"> <thead style="text-align: center;"> <tr> <td style="width: 5%;"> # </td> <td> STATISTICS </td> <td style="width: 15%;"> COUNT </td> <td style="width: 15%;"> TOTAL TAX </td> <td style="width: 15%;"> TOTAL NET. AMOUNT </td> <td style="width: 15%;"> TOTAL AMOUNT </td> </tr> </thead> <tbody style="text-align: center;"> <tr style="margin-top: 20px;"> <?php $sale = new sales(); $vals = $sale->getOneDaysSaleStatistics($user->company_id, $date); ?> <td>1</td> <td style="text-align: left;">SALES</td> <td><?php echo $vals['count']; ?></td> <td><?php echo number_format($vals['tax_amount'], 2, '.',''); ?></td> <td><?php echo number_format($vals['net_amount'], 2, '.',''); ?></td> <td><?php echo number_format($vals['amount'], 2, '.',''); ?></td> </tr> </tbody> </table> <?php */ ?> </div> </div> <script type="text/javascript"> function load_monthly_report(){ var year = $('input#year_field').val(); if(year<2015 || year>2065){ alert('Enter a valid year !'); return; } var month = $('select#month_field').val(); get_form(33, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }, year+'/'+month); } function on_print_clicked() { var year = $('input#year_field').val(); var month = $('select#month_field option:selected').html(); $('div#print_container_header') .html('<font style="color:#21ACD7; font-size:20px; ">MONTHLY REPORT OF '+year+' '+month+'</font>'); var html = $('div#content_table').html(); $('div#print_container_body').html(html); print(); $('div#print_container_header').empty(); $('div#print_container_body').empty(); $('div#print_container_footer').empty(); } </script> <?php $form = ob_get_clean(); return $form; }
function get_form_html($form_id, $date) { ob_start(); ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> SALES REPORT OF <input id="date_field" value="<?php if ($date == 0) { $date = date('d/m/Y', time()); } echo $date; ?> " /> </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr> <td> # </td> <td> ID </td> <td> DATE & TIME </td> <td> CUSTOMER </td> <td style=""> TAX </td> <td style=""> NET. AMOUNT </td> <td style=""> TOTAL </td> <td style=""> </td> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $sale_obj = new sales(); $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $date = str_replace('/', '-', $date); $date = date('Y-m-d', strtotime($date)); $sales = $sale_obj->getSalesOfADay($user->company_id, $date); $i = 0; if (is_array($sales) and count($sales) != 0) { foreach ($sales as $sale) { ?> <tr id="<?php echo $sale->id; ?> " onclick="select_row(this)" status="not_selected" > <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td> <?php echo $sale->id; ?> </td> <?php $date = date('d/m/Y', strtotime($sale->sale_at) + 5.5 * 60 * 60); $time = date('h:m A', strtotime($sale->sale_at) + 5.5 * 60 * 60); ?> <td id="date" date="<?php echo $date; ?> " time="<?php echo $time; ?> "> <?php echo $date . ' - ' . $time; ?> </td> <?php $customer = new customer(); $customer->id = $sale->customer_id; $customer->getCustomer(); ?> <td id="customer" c_name="<?php echo $customer->customer_name; ?> " c_id="<?php echo $customer->id; ?> " > <?php echo $customer->customer_name . ' ( ID : ' . $customer->id . ' )'; ?> </td> <td id="tax"> <?php echo $sale->tax_amount; ?> </td> <td id="net_amount"> <?php echo $sale->net_amount; ?> </td> <td id="total"> <?php echo $sale->amount; ?> </td> <td id="down_button" style="width: 20px;text-align: center; padding: 10px;"> <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer;" onclick="toggle_items_visibility(this)" src="../ui/images/down_arrow.png"/> <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer; display: none;" onclick="toggle_items_visibility(this)" src="../ui/images/up_arrow.png"/> </td> </tr> <tr style="display: none;"> <td colspan="8" style="padding:0 0 20px 0;"> <table id="sale_items" style="border-collapse: collapse; background-color: #c0effd; width: 80%; color: #21ACD7; float: right;"> <thead> <tr> <td> ITEM </td> <td> QUANTITY </td> <td> RATE </td> <td> NET. AMOUNT </td> <td> TAX </td> <td> TOTAL </td> </tr> </thead> <tbody> <?php if (is_array($sale->getSalesItems()) and count($sale->getSalesItems())) { foreach ($sale->getSalesItems() as $s_item) { ?> <tr id="<?php echo $s_item->id; ?> "> <?php $item = new item(); $item->id = $s_item->item_id; $item->getItem(); ?> <td id="item" item_name="<?php echo $item->item_name; ?> "><?php echo $item->item_name . ' - ' . $item->item_code; ?> </td> <td id="quantity" val="<?php echo $s_item->quantity; ?> "> <?php echo number_format($s_item->quantity, 3, '.', ''); ?> </td> <td id="rate" val="<?php echo $s_item->rate; ?> "> <?php echo number_format($s_item->rate, 2, '.', ''); ?> </td> <td> <?php echo number_format($s_item->quantity * $s_item->rate - $s_item->tax, 2, '.', ''); ?> </td> <?php $tax_category = new tax_category(); $tax_category->id = $item->tax_category_id; $tax_category->getTaxCategory(); ?> <td id="tax" val="<?php echo $s_item->tax; ?> " tax_rate="<?php echo $tax_category->tax_percentage; ?> "> <?php echo number_format($s_item->tax, 2, '.', ''); ?> </td> <td id="total" val="<?php echo $s_item->quantity * $s_item->rate; ?> "> <?php echo number_format($s_item->quantity * $s_item->rate, 2, '.', ''); ?> </td> </tr> <?php } } else { echo '<tr><td colspan="6">No item found</td></tr>'; } ?> </tbody> </table> </td> </tr> <?php } } else { echo '<tr><td colspan="8"> No Sales Found </td></tr>'; } ?> </tbody> </table> </div> </div> <script type="text/javascript"> function load_sales_report(){ var date = $('input#date_field').val(); get_form(15, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }, date); } function toggle_items_visibility(down_button) { var row = $(down_button).closest('tr'); row.next('tr').fadeToggle(); row.find('img#toggle_button').toggle(); } function on_print_clicked() { var selected_row = $('tr[status="selected"]'); var sale_items_table = selected_row.next('tr').find('table#sale_items'); var sale_items = sale_items_table.find('tbody').children(); var items = new Array(); var i = 0; sale_items.each(function() { var item_name = $(this).find('td#item').attr('item_name'); var id = $(this).attr('id'); var quantity = $(this).find('td#quantity').attr('val'); var rate = $(this).find('td#rate').attr('val'); var tax = $(this).find('td#tax').attr('val'); var total = $(this).find('td#total').attr('val'); total = parseFloat(total); total = total.toFixed(2); var item = { id: id, quantity: quantity, rate: rate, item_name: item_name, total: total, tax: tax } items[i++] = item; }); var c_name = selected_row.find('td#customer').attr('c_name'); var c_id = selected_row.find('td#customer').attr('c_id'); if(c_id == 0){ c_name = 'Not Regd.'; } var sale_id = selected_row.attr('id'); var total = selected_row.find('td#total').html(); total = parseFloat(total); total = total.toFixed(2); var total_tax = selected_row.find('td#tax').html(); total_tax = parseFloat(total_tax); total_tax = total_tax.toFixed(2); var net_total = selected_row.find('td#net_amount').html(); net_total = parseFloat(net_total); net_total = net_total.toFixed(2); var date = selected_row.find('td#date').attr('date'); var time = selected_row.find('td#date').attr('time'); var data = { customer_id: c_id, total: total, net_amount: net_total, tax_amount: total_tax, items: items, date: date, time: time } print_bill(data, c_name, sale_id); } function print_bill(data, customer_name, sale_id) { var html = ''; html ='<img id="logo_bill" src="images/nutiez.png"/><br/><font id="print_container_header_company_adderss">Royal Piknik Traders LLP, 29/861</font>' +'<br/><font id="print_container_header_company_adderss">Parayancheri, Calicut</font><br/><font id="print_container_header_company_adderss">' +'Phone : 0495 2741095,+91 9388627725</font><br/><font id="print_container_header_company_adderss">The kerala value added tax rules 2005/ form no. 8</font>' +'<br/><font id="print_container_header_company_adderss">Tin : 32110844692</font>' +'<br/><font id="print_container_header_company_adderss">True Copy</font>'; $('div#print_container_header').html(html); html = ''; html = html + "<div<!-- style=\"padding:10px 0;\"><table style=\"float:right;font-size: 12px;\">" +"<tr><td>Date</td><td>:</td><td style=\"text-align:right;\">" + data.date + "</td></tr>" +"<tr><td>Time</td><td>:</td><td style=\"text-align:right;\">" + data.time + "</td></tr></table>"; html = html + "<table style=\"font-size: 12px;\">" +"<tr><td>Bill No.</td><td>:</td><td>" + sale_id + "</td></tr>" +"<tr><td>Cust. ID</td><td>:</td><td>" + data.customer_id + "</td></tr>" +"<tr><td>Cust. Name</td><td>:</td><td>" + customer_name + "</td></tr></table></div>"; html = html + "<div style=\"border-top:1px dashed #000; margin:10px auto 0 auto;padding:0 0 10px 0;\">" + "<table style=\"width:100%;font-size: 12px;\"><tr style=\"border-bottom: 1px solid #000; border-top: 1px solid #000;\">" + "<td style=\"width:45%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px;\">Description</td>" + "<td style=\"width:17%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Qty</td>" + "<td style=\"width:17%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Rate</td>" // + "<td style=\"width:15%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Amount</td>" // + "<td style=\"width:10%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Tax</td>" + "<td style=\"width:21%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Total</td></tr>"; var i = 0; for (var key in data.items) { var item = data.items[key]; html = html + "<tr><td>" + item.item_name + "</td>" +"<td style=\"text-align:right;\">" + parseFloat(item.quantity).toFixed(3) + "</td>" +"<td style=\"text-align:right;\">" + parseFloat(item.rate).toFixed(2) + "</td>" //+"<td style=\"text-align:right;\">" + (parseFloat(item.total) - parseFloat(item.tax)) + "</td>" // +"<td style=\"text-align:right;\">" + item.tax + "</td>" +"<td style=\"text-align:right;\">" + parseFloat(item.total).toFixed(2) + "</td>" +"</tr>"; } html = html + "</table></div>"; html = html + "<div style=\"border-top:1px dashed #000; padding:10px 0;\"><table style=\"margin-left: auto;font-size: 12px;\">"; html = html + "<tr><td>Net. Amount</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.net_amount + "</td></tr>"; html = html + "<tr><td>Tax</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.tax_amount + "</td></tr>"; html = html + "<tr style=\"font-size:18px;\"><td><b>Total</b></td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\"><b>" + data.total + "</b></td></tr>"; html = html + "</table></div>"; // console.log("Creating bill : " + html); $('div#print_container_body').html(html); html = ''; html = '<font>Thank you for shoping</font><br/><font>Visit again...</font> '; $('div#print_container_footer').html(html); print(); $('div#print_container_header').empty(); $('div#print_container_body').empty(); $('div#print_container_footer').empty(); } function select_row(row) { var j_row = $(row); if(j_row.attr('status') == 'selected'){ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); $('img#edit').css('display', 'none'); $('img#edit_fade').css('display', 'block'); $('img#print').css('display', 'none'); $('img#print_fade').css('display', 'block'); }else{ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); j_row.attr('status', 'selected'); j_row.css('background-color', '#C0EFFD'); $('img#edit').css('display', 'block'); $('img#edit_fade').css('display', 'none'); $('img#print').css('display', 'block'); $('img#print_fade').css('display', 'none'); } } function setup_datepicker(){ $('input#date_field').datepick({ minDate:'26/04/2015', dateFormat:'dd/mm/yyyy', maxDate:'0', onSelect:function(){ load_sales_report(); } }); } setup_datepicker(); </script> <?php $form = ob_get_clean(); return $form; }
function get_form_html($form_id, $id) { ob_start(); ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> UN-STOCKED PURCHACES </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr> <td> # </td> <td> ID </td> <td> DATE </td> <td style=""> PURCHACED FROM </td> <td style=""> PURCHACED BY </td> <td style=""> AMOUNT </td> <td style=""> </td> <td style=""> </td> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $purchace_obj = new purchaces(); $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $purchaces = $purchace_obj->getNotStockedPurchaces($user->company_id); $i = 0; if ($purchaces == NULL || sizeof($purchaces) == 0) { echo '<tr><td colspan="8"> No Purchace Found </td></tr>'; } else { foreach ($purchaces as $purchace) { ?> <tr id="<?php echo $purchace->id; ?> "> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td> <?php echo $purchace->id; ?> </td> <td> <?php echo $purchace->created_at; ?> </td> <td> <?php $vendor = new wendors(); $vendor->id = $purchace->wendor_id; $vendor->getWendor(); echo $vendor->wendor_name; ?> </td> <td> <?php $p_manager = new user(); $p_manager->id = $purchace->purchace_manager_id; $p_manager->getUser(); echo $p_manager->name; ?> </td> <td> <?php echo $purchace->amount; ?> </td> <td id="ok_button" style="width: 20px;text-align: center; padding: 10px;"> <img id="add_to_stock_button" style="width: 20px; height: 20px; cursor: pointer;" onclick="add_to_stock(this)" src="../ui/images/tick_button.png"/> </td> <td id="down_button" style="width: 20px;text-align: center; padding: 10px;"> <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer;" onclick="toggle_items_visibility(this)" src="../ui/images/down_arrow.png"/> <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer; display: none;" onclick="toggle_items_visibility(this)" src="../ui/images/up_arrow.png"/> </td> </tr> <tr id="purchace_item" style="display: none;"> <td colspan="8" style="padding:0 0 20px 0;"> <table style="border-collapse: collapse; background-color: #c0effd; width: 80%; color: #21ACD7; float: right;"> <tr> <td> ITEM </td> <td> QUANTITY </td> <td> PURCHACE RATE </td> <td> MRP </td> <td> TOTAL </td> </tr> <?php foreach ($purchace->getPurchaceItems() as $p_item) { ?> <tr> <td> <?php $item = new item(); $item->id = $p_item->item_id; $item->getItem(); echo $item->item_name . ' - ' . $item->item_code . ' (ID : ' . $item->id . ')'; ?> </td> <td> <?php echo $p_item->quantity; ?> </td> <td> <?php echo $p_item->rate; ?> </td> <td> <?php echo $item->mrp; ?> </td> <td> <?php echo $p_item->quantity * $p_item->rate; ?> </td> </tr> <?php } ?> </table> </td> </tr> <?php } } ?> </tbody> </table> </div> </div> <script type="text/javascript"> function add_to_stock(ok_button) { var row = $(ok_button).closest('tr'); var purchace_id = row.attr('id'); var data = { purchace_id: purchace_id } add_purchace_to_stock(data, function(message) { row.hide(); row.next().hide(); if(row.parent('tbody').children('tr:visible').length==0){ row.parent('tbody').html('<tr><td colspan="8"> No Purchace left more </td></tr>'); } alert(message); }, function(message) { alert(message); }); } function toggle_items_visibility(down_button) { var row = $(down_button).closest('tr'); row.next('tr').fadeToggle(); row.find('img#toggle_button').toggle(); } </script> <?php $form = ob_get_clean(); return $form; }
<?php require_once "../apps/User.php"; $u = new user(); if (!$u->isauth()) { header("Location: logout.php"); } $data = $u->getUser(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>SB Admin 2 - Bootstrap Admin Theme</title> <!-- Bootstrap Core CSS --> <link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> <!-- MetisMenu CSS --> <link href="../bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet"> <!-- Custom CSS --> <link href="../dist/css/sb-admin-2.css" rel="stylesheet">
* @copyright (c) 2008 by bizeway.com * @version $Id$ * @package ArthurXF * @subpackage user */ if (is_object($objWebInit)) { if (!isset($objuser)) { include_once __WEB_ROOT . "/user/class/user.class.php"; include_once __WEB_ROOT . "/user/config/var.inc.php"; include_once "index.php"; $objuser = new user(); $objuser->setDBG($arrGPdoDB); $objuser->arrGPic = $arrGPic; $objuser->arrGSmarty = $arrGSmarty; if (is_object($objWebInit->db)) { $objuser->db = $objWebInit->db; } else { $objuser->db(); } } $arrTopuser = array(); $arrTopuser = $objuser->getUser($_SESSION['user_id']); //print_r($arrTopuser); foreach ($arrTopuser as $k => $v) { $_SESSION['lastlog'] = $arrTopuser[$k]['lastlog']; } //全站公用block @(include '../_block.php'); $arrMOutput["smarty_assign"]['userImg'] = $objuser->arrGPic['FileCallPath']; $arrMOutput["smarty_assign"]['arrTopuser'] = $arrTopuser; }
* @package ArthurXF * @subpackage user */ require_once '../config/config.inc.php'; require_once "../class/user.class.php"; require_once '../../useradmin/checklogin.php'; $objWebInit = new user(); //数据库连接参数 $objWebInit->setDBG($arrGPdoDB); //smarty参数 $arrGSmarty['caching'] = false; $objWebInit->arrGSmarty = $arrGSmarty; $objWebInit->db(); $objWebInit->arrGPic = $arrGPic; $user_id = $_SESSION['user_id']; $arrInfo = current($objWebInit->getUser($user_id)); if ($_SERVER["REQUEST_METHOD"] == "POST") { //图片上传 if ($_FILES['Filedata']['name'] != "") { $strOldFile = $arrGPic['FileSavePath'] . 's/' . $_POST['savefilename']; if (is_file($strOldFile)) { // 缩略图删除 unlink($strOldFile); } $strOldFile = $arrGPic['FileSavePath'] . 'b/' . $_POST['savefilename']; if (is_file($strOldFile)) { // 原文件删除 unlink($strOldFile); } $_POST['photo1'] = $objWebInit->uploadInfoImage($_FILES['Filedata'], '', $_POST['FileListPicSize'], $_POST['csize0'], $arrInfo['user_id']); } else {
function get_form_html($form_id, $id, $page, $limit, $adjacents) { ob_start(); $expence = new expences(); $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $count = $expence->getExpencesCount($user->company_id); if ($page == 1) { $start = 0; $head_message = "LAST {$limit} EXPENCES"; } else { $start = ($page - 1) * $limit; $head_message = "EXPENCES {$start} TO " . ($start + $limit); } ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> <?php echo $head_message; ?> </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <div style="padding: 10px 0; background-color: transparent; border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; "> <?php echo pagination($limit, $adjacents, $count, $page); ?> </div> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr status="not_selected"> <td> # </td> <td> ID </td> <td> DATE AND TIME </td> <td> AMOUNT </td> <td style=""> DESCRIPTION </td> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $expences = $expence->getExpences($user->company_id, $start, $limit); $i = $start; if ($expences == NULL || sizeof($expences) == 0) { echo '<tr><td colspan="8"> No Expence Found </td></tr>'; } else { foreach ($expences as $expence) { ?> <tr id="<?php echo $expence->id; ?> " onclick="select_row(this)" status="not_selected"> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td> <?php echo $expence->id; ?> </td> <?php $date = date('d/m/Y', strtotime($expence->created_at) + 5.5 * 60 * 60); $time = date('h:m a', strtotime($expence->created_at) + 5.5 * 60 * 60); ?> <td> <?php echo $date . ' - ' . $time; ?> </td> <td id="amount"><?php echo number_format($expence->amount, 2, '.', ''); ?> </td> <td id="description"><?php echo $expence->description; ?> </td> </tr> <?php } } ?> </tbody> </table> </div> <div style="padding: 10px 0; background-color: transparent; border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; "> <?php echo pagination($limit, $adjacents, $count, $page); ?> </div> </div> <script type="text/javascript"> function select_row(row) { var j_row = $(row); if(j_row.attr('status') == 'selected'){ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); $('img#edit').css('display', 'none'); $('img#edit_fade').css('display', 'block'); $('img#delete').css('display', 'none'); $('img#delete_fade').css('display', 'block'); }else{ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); j_row.attr('status', 'selected'); j_row.css('background-color', '#C0EFFD'); $('img#edit').css('display', 'block'); $('img#edit_fade').css('display', 'none'); $('img#delete').css('display', 'block'); $('img#delete_fade').css('display', 'none'); } } function on_edit_clicked(){ var selected_row = $('tr[status="selected"]'); var amount = selected_row.find('td#amount').html(); var id = selected_row.attr('id'); var description = selected_row.find('td#description').html(); get_form(5, ///expence create form function (html, tools){ $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); var form = $('div#form-body').find('form.action_form'); form.attr('operation', 'update'); form.attr('expence_id', id); form.find('input#amount').val(amount); form.find('textarea#description').val(description); form.find('input[type=submit]').val('UPDATE'); $('div#head_div').html('ID : EXPENCE-'+id); $('div#head_div').css('display', 'block'); }, function (message){ $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); } ); } function on_delete_clicked(){ var selected_row = $('tr[status="selected"]'); var id = selected_row.attr('id'); if(confirm('Are you sure you want to delete EXPENCE-'+id+' ?' )){ var data = { form_id : 31, expence_id : id } delete_form_data(data, function(message) { get_form(31, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }); alert(message); }, function(message) { alert(message); }); } } function set_pagination_listener(){ $('.pagination').on('click','.page-numbers',function(e){ e.preventDefault(); var page = $(this).attr('page'); var id = 0; get_form(31, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); alert(message); },id ,page ); return false; }); } set_pagination_listener(); </script> <?php $form = ob_get_clean(); return $form; }
function get_form_html($form_id, $id) { ob_start(); ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> <?php $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $company = new company(); $company->id = $user->company_id; $company->getCompany(); echo "STOCK REPORT OF {$company->company_name} - {$company->company_code}"; ?> </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items th{ border: 1px solid #21ACD7; } div#purchace_items tbody th{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <input type="text" id="search" placeholder="Enter Search Key here..." style="width: 100%; margin-left: 0px;" onkeyup="search()" /> <style> img#search{ position: relative; height: 20px; width: 20px; float: right; top: -29px; right: 10px; } </style> <img id="search" src="../ui/images/search.png" onclick="search()" /> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr> <th> # </th> <th> ITEM </th> <th> STOCK COUNT </th> <th style=""> SELLING PRIZE </th> <th style=""> TAX </th> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $inventry = new inventry(); $inventries = $inventry->getInventryForSpecificCompany($user->company_id); $i = 0; if ($inventries == NULL || sizeof($inventries) == 0) { echo '<tr><td colspan="8"> No Stock Found </td></tr>'; } else { foreach ($inventries as $inventry) { ?> <tr id="<?php echo $inventry->id; ?> " > <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td> <?php $item = new item(); $item->id = $inventry->item_id; $item->getItem(); echo $item->item_name . ' - ' . $item->item_code; ?> </td> <td> <?php echo number_format($inventry->in_stock_count, 3, '.', ''); ?> </td> <td> <?php echo number_format($inventry->selling_prize, 2, '.', ''); ?> </td> <td> <?php $tax = new tax_category(); $tax->id = $inventry->tax_category_id; $tax->getTaxCategory(); echo $tax->tax_category_name; ?> </td> </tr> <?php } } ?> </tbody> </table> </div> </div> <script type="text/javascript"> function search(){ var search_key = $('input#search').val(); if(search_key !== ''){ console.log("search key "+ search_key); searchTable(search_key); }else{ $('#items_table tr').show(); } } function searchTable(inputVal) { var table = $('#items_table'); table.find('tr').each(function(index, row) { var allCells = $(row).find('td'); if(allCells.length > 0) { var found = false; allCells.each(function(index, td) { var regExp = new RegExp(inputVal, 'i'); if(regExp.test($(td).text())) { found = true; return false; } }); if(found == true)$(row).show();else $(row).hide(); } }); } </script> <?php $form = ob_get_clean(); return $form; }
$arrComments = $aComments->getRecords("id_article=" . secure::escQuoteData($_POST['getCommentsA']) . " AND token='active' ORDER BY datetime " . $order, false, false, false); $smarty->assignByRef('author', $author); $smarty->assignByRef('order', $order); $smarty->assignByRef('arrComments', $arrComments); } $smarty->assignByRef('errors', $arrErrors); $smarty->display('articles.comments.list.tpl'); } elseif (isset($_POST['complaintCommentA'])) { if (!empty($_POST['complaintCommentA'])) { $articles = new articles(); $aComments = new articlesComments(); if ($arrComment = $aComments->getRecord("id=" . secure::escQuoteData($_POST['complaintCommentA'] . " AND token='active'"))) { if ($arrData = $articles->getPublishedArticle("id=" . secure::escQuoteData($arrComment['id_article']))) { if (!empty($arrData['id_user'])) { $user = new user(); $recipient = ($arrUser = $user->getUser("id=" . secure::escQuoteData($arrData['id_user']) . " AND token='active'")) ? $arrUser['email'] : CONF_MAIL_ADMIN_EMAIL; } else { $recipient = CONF_MAIL_ADMIN_EMAIL; } if ($aComments->sendComplaintComment($arrComment, $arrData, $recipient)) { echo ajax::sdgJSONencode(array('success' => MESSAGE_COMMENTS_COMPLAINT_SEND)); } else { echo ajax::sdgJSONencode(array('error' => MESSAGE_COMMENTS_COMPLAINT_NOT_SEND)); } } else { echo ajax::sdgJSONencode(array('error' => MESSAGE_COMMENTS_COMPLAINT_NOT_SEND)); } } else { echo ajax::sdgJSONencode(array('error' => MESSAGE_COMMENTS_COMPLAINT_NOT_SEND)); } } else {
/** * @brief Return the user record of the active user * * Returns null if no user is authenticated * * @todo Gracefully handle situations where the session is not available * @return UserRecord The UserRecord of the active user */ static function getActiveUser() { if (ModuleManager::has('lepton.mvc.session')) { $uid = session::get(User::KEY_USER_AUTH, null); if ($uid) { return user::getUser($uid); } throw new UserException("No active user", UserException::ERR_NO_ACTIVE_USER); } }
function get_form_html($form_id, $id) { ob_start(); ?> <style> .field_name{ width: 20%; } .field{ width: 50%; } .field input{ width: 100%; margin-left: 0px; } .field .parent{ padding: 0px 0px; } .field select{ width: 100%; } </style> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> ID : SALE - <input style="padding: 0 0 0 5px;" onchange="load_sale()" type="number" id="sale_id" /> </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <form action="#" method="post" onsubmit="return false" class="action_form" operation="update" style="width:100%;"> <table style="width:100%;"> <tr> <td class="field_name"> <font>CUSTOMER</font> </td> <td class="field"> <div class="parent"> <input id="customer_id" onfocus="$(this).css('border', '0px')" list="customers" autocomplete="off" style="border: 0;" disabled/> </div> </td> </tr> <tr> <td class="field_name"> <font>DATE & TIME</font> </td> <td class="field"> <div class="parent"> <input id="date_and_time" disabled autocomplete="off" style="border: 0;"/> </div> </td> </tr> <tr> <td colspan="2"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr> <td> # </td> <td> ITEM </td> <td style="width: 10%;"> QUANTITY </td> <td style="width: 10%;"> RATE </td> <td style="width: 10%;"> DISCOUNT(%) </td> <td style="width: 10%;"> DISCOUNT </td> <td style="width: 10%;"> TOTAL </td> <td style="width: 8%;"> DELETE </td> </tr> </thead> <tbody style="padding-left: 3px;"> <datalist id="items"> <?php $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $inv = new inventry(); $invs = array(); $invs = $inv->getInventryForSpecificCompany($user->company_id); if ($invs != NULL and sizeof($invs) != 0) { foreach ($invs as $inv) { if ($inv->in_stock_count > 0) { $item = new item(); $item->id = $inv->item_id; $item->getItem(); $tax_category = new tax_category(); $tax_category->id = $inv->tax_category_id; $tax_category->getTaxCategory(); echo $tax_category->to_string(); echo '<option id="' . $item->id . '"' . ' stock_count="' . $inv->in_stock_count . '"' . ' selling_pize="' . $inv->selling_prize . '"' . ' tax="' . $tax_category->tax_percentage . '"' . ' discount_percent="' . $item->discount_percent . '"' . ' item_name="' . $item->item_name . '"' . ' value="' . $item->item_name . ' - ' . $item->item_code . '" >' . $item->item_name . ' - ' . $item->item_code . '</option>'; } } } ?> </datalist> <tr status="active" slno="1"> <td style="text-align: center;">1</td><td> <input type="text" onchange="update_item_details(this)" oninput="update_item_details(this)" onfocus="$(this).css('border', '0px')" autocomplete="off" list="items" id="item" required /> </td> <td> <input type="number" min="0" step="any" required onchange="calculate_total(this)" oninput="calculate_total(this)" id="quantity"/> </td> <td> <input type="text" value="0" min="0" required disabled onchange="calculate_total(this)" oninput="calculate_total(this)" id="rate"/> </td> <td> <input type="number" step="0.01" value="0" min="0" max="100" onchange="calculate_total(this)" oninput="calculate_total(this)" id="discount_percent"/> </td> <td> <input type="text" value="0" min="0" required disabled id="discount"/> </td> <td> <input type="text" min="0" required id="total" disabled/> </td> <td style="width: 20px; text-align: center; padding-right: 5px;"> <img id="delete_button" onclick="delete_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto; margin-left: auto;" src="../ui/images/cross_button.png"/> <img id="activate_button" onclick="enable_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto; margin-left: auto; display: none;" src="../ui/images/tick_button.png" /> </td> </tr> <tr status="active" slno="2"> <td style="text-align: center;">2</td><td> <input type="text" onchange="update_item_details(this)" oninput="update_item_details(this)" onfocus="$(this).css('border', '0px')" autocomplete="off" list="items" id="item" required /> </td> <td> <input type="number" min="0" step="any" required onchange="calculate_total(this)" onkeyup="calculate_total(this)" id="quantity"/> </td> <td> <input type="text" value="0" min="0" required disabled onchange="calculate_total(this)" onkeyup="calculate_total(this)" id="rate"/> </td> <td> <input type="number" step="0.01" value="0" min="0" max="100" onchange="calculate_total(this)" oninput="calculate_total(this)" id="discount_percent"/> </td> <td> <input type="text" value="0" min="0" required disabled id="discount"/> </td> <td> <input type="text" min="0" required id="total" disabled/> </td> <td style="width: 20px; text-align: center; padding-right: 5px;"> <img id="delete_button" onclick="delete_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto; margin-left: auto;" src="../ui/images/cross_button.png"/> <img id="activate_button" onclick="enable_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto; margin-left: auto; display: none;" src="../ui/images/tick_button.png" /> </td> </tr> </tbody> </table> </div> </td> </tr> <tr style="height: 5px;"></tr> <tr> <td></td> <td> <div style="background-color: #21ACD7; color: #fff; text-align: right; padding-right: 20px;"> <span style="margin-right: 20px;">TOTAL </span> <span id="total">0.00</span> </div> </td> </tr> <tr style="display: none;"> <td></td> <td> <div style="background-color: #21ACD7; color: #fff; text-align: right; padding-right: 20px;"> <span style="margin-right: 20px;">DISCOUNT </span> <span id="discount">0.00</span> </div> </td> </tr> <tr> <td></td> <td> <div style="background-color: #21ACD7; color: #fff; text-align: right; padding-right: 20px;"> <span style="margin-right: 20px;">PAID </span> <span id="total_paid">0.00</span> </div> </td> </tr> <tr> <td></td> <td> <div style="background-color: #21ACD7; color: #fff; text-align: right; padding-right: 20px;"> <span style="margin-right: 20px;">BALANCE</span> <span id="balance">0.00</span> </div> </td> </tr> <tr style="height: 5px;"></tr> <tr> <td></td> <td> <div style="padding: 0px 12px;"> <div style="width: 100%; margin-left: -12px; padding: 12px; background-color: #0d92bb; border-radius: 5px; float: left;"> <div style="width: 33.33%; float: right; "> <input style="width: 100%;" type="submit" value="UPDATE" /> </div> <div style="width: 33.33%; float: right; "> <input style="width: 100%;" type="reset" value="CANCEL" /> </div> <div style="width: 33.33%;"> <input style="width: 100%;" onclick="add_sale_item()" type="button" value="ADD ITEM" /> </div> </div> </div> </td> </tr> </table> </form> </div> <script type="text/javascript"> function update_item_details(item) { var item_input = $(item); var item_name = item_input.val(); var item_option_obj = $('datalist#items').find("option[value='" + item_name + "']"); if (item_option_obj.length == "0") { return; } else { var selling_prize = item_option_obj.attr('selling_pize'); var stock_count = item_option_obj.attr('stock_count'); var tax = item_option_obj.attr('tax'); var discount_percent = item_option_obj.attr('discount_percent'); if($.isNumeric(discount_percent)){ discount_percent = parseFloat(discount_percent).toFixed(2); }else{ discount_percent = 0; } var row = item_input.parent('td').parent('tr'); row.find('input#rate').val(selling_prize); row.find('input#rate').attr('tax', tax); row.find('input#discount_percent').val(discount_percent); row.find('input#quantity').prop('max', stock_count); calculate_total(row.find('input#rate').get(0)); } } function calculate_total(field) { var $parent = $(field).closest('tr'); var $quantity = parseFloat($parent.find('input#quantity').val()); var $rate = parseFloat($parent.find('input#rate').val()); var $total = $quantity * $rate; $total = $total.toFixed(2); if ($.isNumeric($total)) { var discount_percent = parseFloat($parent.find('input#discount_percent').val()); var discount = ($total * discount_percent) / 100; if($.isNumeric(discount)){ //$parent.find('input#total').attr('discount', discount); $parent.find('input#discount').val(discount); $total = $total - discount; }else{ //$parent.find('input#total').attr('discount', 0); $parent.find('input#discount').val(0); } $parent.find('input#total').val($total); var $tax_percentage = parseFloat($parent.find('input#rate').attr('tax')); var $tax = ($total * $tax_percentage) / (100 + $tax_percentage); //$tax = $tax.toFixed(2); if($.isNumeric($tax)){ $parent.find('input#total').attr('tax', $tax); }else{ $parent.find('input#total').attr('tax', 0); } } else { $parent.find('input#total').val(0); $parent.find('input#total').attr('tax', 0); $parent.find('input#total').attr('discount', 0); //$parent.find('input#discount').val(0); } calculate_purchace_total(); } function calculate_purchace_total() { var items_table = $('#items_table').find('tbody').children(); var total = 0; var total_tax = 0; var total_discount = 0; items_table.each(function() { var item_total_input = $(this).find('input#total'); var row_status = $(this).attr('status'); var item_total = item_total_input.val(); var item_tax = item_total_input.attr('tax'); var item_discount = $(this).find('input#discount').val(); if ($.isNumeric(item_total) && row_status == 'active') { total = parseFloat(total) + parseFloat(item_total); if($.isNumeric(item_tax)){ total_tax = parseFloat(total_tax) + parseFloat(item_tax); } if($.isNumeric(item_discount)){ total_discount = parseFloat(total_discount) + parseFloat(item_discount); } } }); total = total.toFixed(2); total_tax = total_tax.toFixed(2); $('span#total').html(total); $('span#total').attr('tax', total_tax); var paid = $('span#total_paid').html(); paid = parseFloat(paid); var balance = total - paid; balance = balance.toFixed(2); $('span#balance').html(balance); total_discount = total_discount.toFixed(2); $('span#total').attr('discount', total_discount); $('span#discount').val(total_discount); } function delete_this_row(delete_btn) { var row = $(delete_btn).closest('tr'); row.attr('status', 'deativated'); row.css('background-color', '#c0effd'); row.find('input').prop('required', null); row.find('input').css('border', "0px"); $(delete_btn).css('display', 'none'); $(delete_btn).siblings().first().css('display', 'block'); $(delete_btn).parent('td').css('text-align', 'centre'); calculate_purchace_total(); } function enable_this_row(enable_btn) { var row = $(enable_btn).closest('tr'); row.attr('status', 'active'); row.css('background-color', '#fff'); row.find('input').prop('required', 'required'); $(enable_btn).siblings().first().css('display', 'block'); $(enable_btn).css('display', 'none'); $(enable_btn).parent('td').css('text-align', 'centre'); calculate_purchace_total(); } function add_sale_item() { var row = '<tr status="active" slno="" previous="false"><td style="text-align: center;"></td><td>' + '<input type="text" onchange="update_item_details(this)" oninput="update_item_details(this)" onfocus="$(this).css(\'border\', \'0px\')" autocomplete="off" list="items" id="item" required />' + '</td><td><input type="number" min="0" step="any" required onchange="calculate_total(this)" onkeyup="calculate_total(this)" id="quantity"/>' + '</td><td><input type="text" value="0" min="0" required disabled onchange="calculate_total(this)" onkeyup="calculate_total(this)" id="rate"/>' + '</td><td><input type="number" step="0.01" value="0" min="0" max="100" onchange="calculate_total(this)" oninput="calculate_total(this)" id="discount_percent"/>' + '</td><td><input type="text" value="0" min="0" required disabled id="discount"/>' + '</td><td><input type="text" min="0" required id="total" disabled/></td><td style="width: 20px; text-align: center; padding-right: 5px;">' + '<img id="delete_button" onclick="delete_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto; margin-left: auto;" src="../ui/images/cross_button.png"/>' + '<img id="activate_button" onclick="enable_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto; margin-left: auto; display: none;" src="../ui/images/tick_button.png" />' + '</td></tr>'; var lastcount = $('table#items_table tbody tr:last-child').attr('slno'); if(!($.isNumeric(lastcount))){ lastcount = 0; } $('table#items_table tbody').append(row); lastcount = parseInt(lastcount) + 1; $('table#items_table tbody tr:last-child').attr('slno', lastcount); $('table#items_table tbody tr:last-child td:first-child').html(lastcount); } function load_sale(){ var sale_id = $('input#sale_id').val(); var data = { form_id: 2, sale_id: sale_id } get_form_data(data, function(message, sale) { //alert(message); var form = $('form.action_form'); form.find('input#customer_id').val(sale.customer); form.find('input#date_and_time').val(sale.date + ' - ' + sale.time); form.find('input#date_and_time').attr('date', sale.date); form.find('input#date_and_time').attr('time', sale.time); form.find('input#customer_id').attr('disabled', 'true'); $('table#items_table tbody').empty(); var items = sale.items; for(var i = 0; i<items.length; i++){ add_sale_item(); var row = $('table#items_table tbody tr:last-child'); var item = items[i]; row.find('input#item').attr('disabled', 'disabled'); row.find('input#item').val(item.item_name); row.find('input#item').attr('item_id', item.item_id); row.find('input#quantity').val(item.quantity); row.find('input#quantity').attr('max', item.quantity); row.find('input#rate').val(item.rate); row.find('input#rate').attr('tax', item.tax_rate); row.find('input#discount_percent').val(item.discount_percent); row.find('input#total').val(item.total); row.find('input#total').attr('tax', item.tax); row.find('input#total').attr('discount', item.discount); row.find('input#discount').val(item.discount); row.attr('previous', true); } form.find('span#total').html(sale.amount); form.find('span#total').attr('tax', sale.tax); form.find('span#total').attr('discount', sale.discount); form.find('span#discount').html(sale.discount); form.find('span#total_paid').html(sale.amount); form.find('span#balance').html('0.00'); form.attr('sale_id', sale.id); form.attr('customer_name', sale.c_name); form.attr('customer_id', sale.c_id); form.find('input[type="button"]').prop('disabled', null); form.find('input[type="submit"]').prop('disabled', null); form.find('input[type="reset"]').prop('disabled', null); form.find('input[type="number"]').prop('disabled', null); }, function(message) { var form = $('form.action_form'); form.find('input').prop('disabled', 'disabled'); alert(message); }); } $(document).ready(function(e) { $('form.action_form').on('submit', function(e) { e.preventDefault(); var items = new Array(); var i = 0; var items_table = $('#items_table').find('tbody').children(); var invalid_item_precent = false; items_table.each(function() { if ($(this).attr('status') == 'active') { var item_input = $(this).find('input#item'); var item_name = item_input.val(); var item_option_obj = $('datalist#items').find("option[value='" + item_name + "']"); if (item_option_obj.length == "0" && !$(this).attr('previous')) { item_input.css('border', '1px solid #f00'); invalid_item_precent = true; return; } else { var id; if($(this).attr('previous') == 'true'){ id = item_input.attr('item_id'); }else{ id = item_option_obj.attr('id'); //var item_name = item_option_obj.attr('item_name'); } var quantity = $(this).find('input#quantity').val(); quantity = parseFloat(quantity).toFixed(3); var rate = $(this).find('input#rate').val(); var tax_rate = $(this).find('input#rate').attr('tax'); rate = parseFloat(rate).toFixed(2); var tax = $(this).find('input#total').attr('tax'); var discount = $(this).find('input#discount').val(); var total = $(this).find('input#total').val(); var item = { id: id, quantity: quantity, rate: rate, item_name: item_name, total: total, tax: tax, discount: discount, tax_rate:tax_rate } items[i++] = item; } } }); if (invalid_item_precent) { //alert("Invalid Item Precent"); return; } var form_id = 2; var operation = $(this).attr('operation'); var total = $('span#total').html(); var total_tax = $('span#total').attr('tax'); var total_discount = $('span#total').attr('discount'); var net_total = parseFloat(total) - parseFloat(total_tax); net_total = net_total.toFixed(2); var total_paid = $('span#total_paid').html(); total_paid = parseFloat(total_paid); total_paid = total_paid.toFixed(2); var balance = $('span#balance').html(); balance = parseFloat(balance); balance = balance.toFixed(2); var sale_id = $(this).attr('sale_id'); var customer_name = $(this).attr('customer_name'); var customer_id = $(this).attr('customer_id'); var date = $(this).find('input#date_and_time').attr('date'); var time = $(this).find('input#date_and_time').attr('time'); if(items.length == 0){ items = 'no_items'; } if (operation == 'update') { var data = { form_id: form_id, sale_id: sale_id, total: total, net_amount: net_total, tax_amount: total_tax, discount:total_discount, items: items } update_form_data(data, function(message, sale_id) { //$('form.action_form').get(0).reset(); //alert(message); print_bill(data, customer_name, customer_id, sale_id, total_paid, balance, date, time); get_form(2, function(html) { $('div#form-body').html(html); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }); }, function(message) { alert(message); }); } else { alert("Invalid Operation " + form_id + ' - ' + operation); } }); function print_bill(data, customer_name, customer_id, sale_id, total_paid, balance, date, time) { var html = ''; html ='<img id="logo_bill" src="images/nutiez.png"/><br/><font id="print_container_header_company_adderss">Royal Piknik Traders LLP, 29/861</font>' +'<br/><font id="print_container_header_company_adderss">Parayancheri, Calicut</font><br/><font id="print_container_header_company_adderss">' +'Phone : 0495 2741095,+91 9388627725</font><br/><font id="print_container_header_company_adderss">The kerala value added tax rules 2005/ form no. 8</font>' +'<br/><font id="print_container_header_company_adderss">Tin : 32110844692</font>' +'<br/><font id="print_container_header_company_adderss">True Copy</font>'; $('div#print_container_header').html(html); html = "<div<!-- style=\"padding:10px 0;\"><table style=\"float:right; font-size: 12px;\">" +"<tr><td>Date</td><td>:</td><td style=\"text-align:right;\">" + date + "</td></tr>" +"<tr><td>Time</td><td>:</td><td style=\"text-align:right;\">" + time + "</td></tr></table>"; html = html + "<table style=\"font-size: 12px;\">" +"<tr><td>Bill No.</td><td>:</td><td>" + sale_id + "</td></tr>" +"<tr><td>Cust. ID</td><td>:</td><td>" + customer_id + "</td></tr>" +"<tr><td>Cust. Name</td><td>:</td><td>" + customer_name + "</td></tr></table></div>"; html = html + "<div style=\"border-top:1px dashed #000; margin:10px auto 0 auto;padding:0 0 10px 0;\">" + "<table style=\"width:100%;font-size: 12px;\"><tr style=\"border-bottom: 1px solid #000; border-top: 1px solid #000;\">" + "<td style=\"width:44%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px;\">Description</td>" + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Qty</td>" + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Rate</td>" // + "<td style=\"width:15%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Amount</td>" // + "<td style=\"width:10%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Tax</td>" + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Tax(%)</td>" + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Total</td></tr>"; var i = 0; if(data.items == 'no_items'){ html = html + "<tr><td> No item</td></tr>"; }else{ for (var key in data.items) { var item = data.items[key]; html = html + "<tr><td>" + item.item_name + "</td>" +"<td style=\"text-align:right;\">" + parseFloat(item.quantity).toFixed(3) + "</td>" +"<td style=\"text-align:right;\">" + parseFloat(item.rate).toFixed(2) + "</td>" //+"<td style=\"text-align:right;\">" + (parseFloat(item.total) - parseFloat(item.tax)) + "</td>" // +"<td style=\"text-align:right;\">" + item.tax + "</td>" +"<td style=\"text-align:right;\">" + item.tax_rate + "</td>" +"<td style=\"text-align:right;\">" + parseFloat(item.total).toFixed(2) + "</td>" +"</tr>"; } } html = html + "</table></div>"; html = html + "<div style=\"border-top:1px dashed #000; padding:10px 0;\"><table style=\"margin-left: auto;font-size: 12px;\">"; html = html + "<tr><td>Net. Amount</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.net_amount + "</td></tr>"; if(parseFloat(data.discount) > 0 ){ html = html + "<tr><td>Discount</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.discount + "</td></tr>"; } html = html + "<tr><td>Tax</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.tax_amount + "</td></tr>"; html = html + "<tr><td>Total</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.total + "</td></tr>"; html = html + "<tr><td>Paid</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + total_paid + "</td></tr>"; html = html + "<tr style=\"font-size:18px;\"><td><b>Balance</b></td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\"><b>" + balance + "</b></td></tr>"; html = html + "</table></div>"; // console.log("Creating bill : " + html); $('div#print_container_body').html(html); html = ''; html = '<font>Thank you for shoping</font><br/><font>Visit again...</font> '; $('div#print_container_footer').html(html); print(); $('div#print_container_header').empty(); $('div#print_container_body').empty(); $('div#print_container_footer').empty(); } }); </script> <?php $form = ob_get_clean(); return $form; }
* 2007-07-19 * * License: * GPL v2 or above * * Website: * http://www.simpleinvoices.org */ //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); #get the invoice id $id = $_GET['id']; $user = user::getUser($id); $roles = user::getUserRoles(); $smarty->assign('user', $user); $smarty->assign('roles', $roles); /* $smarty -> assign('enabled', array( 0 => $LANG[disabled], 1 => $LANG[enabled] ) ); */ $smarty -> assign('pageActive', 'user');
function get_form_html($form_id, $id) { ob_start(); ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> <?php $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $company = new company(); $company->id = $user->company_id; $company->getCompany(); echo "STOCK REPORT OF {$company->company_name} - {$company->company_code}"; ?> </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td,div#purchace_items th{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <input type="text" id="search" placeholder="Enter Search Key here..." style="width: 100%; margin-left: 0px;" onkeyup="search()" /> <style> img#search{ position: relative; height: 20px; width: 20px; float: right; top: -29px; right: 10px; } </style> <img id="search" src="../ui/images/search.png" onclick="search()" /> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr status="not_selected"> <th> # </th> <th> ITEM </th> <th> STOCK COUNT </th> <th style=""> SELLING PRIZE </th> <th style=""> TAX </th> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $inventry = new inventry(); $inventries = $inventry->getInventryForSpecificCompany($user->company_id); $i = 0; if ($inventries == NULL || sizeof($inventries) == 0) { echo '<tr><td colspan="8"> No Stock Found </td></tr>'; } else { foreach ($inventries as $inventry) { ?> <tr id="<?php echo $inventry->id; ?> " onclick="select_row(this)" status="not_selected"> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td id="item_name"><?php $item = new item(); $item->id = $inventry->item_id; $item->getItem(); echo $item->item_name . ' (' . $item->item_code . ')'; ?> </td> <td id="in_stock_count"><?php echo number_format($inventry->in_stock_count, 3, '.', ''); ?> </td> <td id="mrp"><?php echo number_format($inventry->selling_prize, 2, '.', ''); ?> </td> <td id="tax_category" tax_category_id="<?php echo $inventry->tax_category_id; ?> "><?php $tax = new tax_category(); $tax->id = $inventry->tax_category_id; $tax->getTaxCategory(); echo $tax->tax_category_name; ?> </td> </tr> <?php } } ?> </tbody> </table> </div> </div> <script type="text/javascript"> function select_row(row) { var j_row = $(row); if(j_row.attr('status') == 'selected'){ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); $('img#edit').css('display', 'none'); $('img#edit_fade').css('display', 'block'); $('img#delete').css('display', 'none'); $('img#delete_fade').css('display', 'block'); }else{ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); j_row.attr('status', 'selected'); j_row.css('background-color', '#C0EFFD'); $('img#edit').css('display', 'block'); $('img#edit_fade').css('display', 'none'); $('img#delete').css('display', 'block'); $('img#delete_fade').css('display', 'none'); } } function on_edit_clicked(){ var selected_row = $('tr[status="selected"]'); var item_name = selected_row.find('td#item_name').html(); var id = selected_row.attr('id'); var instock_count = selected_row.find('td#in_stock_count').html(); var mrp = selected_row.find('td#mrp').html(); var tax_category_id = selected_row.find('td#tax_category').attr('tax_category_id'); get_form(25, ///inventry edit form function (html, tools){ $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); var form = $('div#form-body').find('form.action_form'); form.attr('operation', 'update'); form.attr('inventry_id', id); form.find('input#item_name').val(item_name); form.find('input#in_stock_count').val(instock_count); form.find('input#in_stock_count').prop('disabled', null); form.find('input#mrp').val(mrp); form.find('input#mrp').prop('disabled', null); form.find('select#tax_category').find('option#'+tax_category_id).prop('selected', true); form.find('select#tax_category').prop('disabled', null); form.find('input[type=submit]').val('UPDATE'); form.find('input[type=submit]').prop('disabled', null); form.find('input[type=reset]').prop('disabled', null); $('div#head_div').html('ID : INVENTRY-'+id); $('div#head_div').css('display', 'block'); }, function (message){ $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); } ); } function on_delete_clicked(){ var selected_row = $('tr[status="selected"]'); var id = selected_row.attr('id'); if(confirm('Are you sure you want to delete INVENTRY-'+id+' ?' )){ var data = { form_id : 20, inventry_id : id } delete_form_data(data, function(message) { get_form(20, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }); alert(message); }, function(message) { alert(message); }); } } function on_print_clicked() { //var date = $('input#date_field').val(); var d = new Date(); var date = d.getDate()+"/"+(parseInt(d.getMonth())+parseInt(1))+"/"+d.getFullYear(); $('div#print_container_header') .html('<font style="color:#21ACD7; font-size:20px; ">STOCK REPORT OF '+date+'</font>'); var html = $('div#purchace_items').html(); $('div#print_container_body').html(html); print(); $('div#print_container_header').empty(); $('div#print_container_body').empty(); $('div#print_container_footer').empty(); } function search(){ var search_key = $('input#search').val(); if(search_key !== ''){ console.log("search key "+ search_key); searchTable(search_key); }else{ $('#items_table tr').show(); } } function searchTable(inputVal) { var table = $('#items_table'); table.find('tr').each(function(index, row) { var allCells = $(row).find('td'); if(allCells.length > 0) { var found = false; allCells.each(function(index, td) { var regExp = new RegExp(inputVal, 'i'); if(regExp.test($(td).text())) { found = true; return false; } }); if(found == true)$(row).show();else $(row).hide(); } }); } </script> <?php $form = ob_get_clean(); return $form; }
* * (c) 2015 Steve Morgan http://siempresolutions.co.uk/ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once '../../admin-includes/admin.base.inc.php'; require_once '../../admin-includes/admin.security_ajax.inc.php'; $user = new user(); if (isset($_POST['action'])) { //////////////////////////////////////////////////// // loadUser e.g. LOAD USER FROM ID //////////////////////////////////////////////////// if ($_POST['action'] == 'loadUser') { if (isset($_POST['userID']) && is_int((int) $_POST['userID'])) { $foundRecord = $user->getUser((int) $_POST['userID']); echo json_encode(array('result' => $foundRecord, 'results' => $user->results)); exit; } else { echo json_encode(array('result' => 'false')); exit; } } //////////////////////////////////////////////////// // SET - e.g. UPDATE USER //////////////////////////////////////////////////// if ($_POST['action'] == 'set') { if (isset($_POST['user-id']) && isset($_POST['user-forename']) && isset($_POST['user-lastname']) && isset($_POST['user-email'])) { // Validate and sanitise $userID = (int) $_POST['user-id']; $foreName = $_POST['user-forename'];
//registering for class auto loading spl_autoload_register(function ($class_name) { $controller_root = $_SERVER['DOCUMENT_ROOT'] . '/piknik_ims/controller'; if (file_exists($controller_root . '/php_classes/' . $class_name . '.php')) { $file_name = $controller_root . '/php_classes/' . $class_name . '.php'; require_once $file_name; } else { throw new Exception("Class " . $class_name . " Not found"); } }); $user = new user(); if (isset($_SESSION['user_id']) and !empty($_SESSION['user_id']) and isset($_GET['user_id']) and !empty($_GET['user_id']) and $_SESSION['user_id'] === $_GET['user_id']) { $form_id = $_SESSION['user_id']; $user->id = $form_id; $user->getUser(); if ($user == NULL) { $responce = array('status' => 'failed', 'error' => 'Server error occured, Please inform your admin', 'data' => array()); } else { if ($user->user_type_id == 1) { $menu_list = array(array('menu_item_name' => 'Sales Invoice', 'menu_item_id' => '1'), array('menu_item_name' => 'Sales Return', 'menu_item_id' => '2'), array('menu_item_name' => 'Sales Report', 'menu_item_id' => '3'), array('menu_item_name' => 'Day End Report', 'menu_item_id' => '24'), array('menu_item_name' => 'Customer', 'menu_item_id' => '6'), array('menu_item_name' => 'Add to stock', 'menu_item_id' => '16'), array('menu_item_name' => 'Stock Report', 'menu_item_id' => '9'), array('menu_item_name' => 'Help', 'menu_item_id' => '35')); $responce = array('status' => 'success', 'error' => '', 'data' => array('menu_list' => $menu_list)); } else { if ($user->user_type_id == 2) { $menu_list = array(array('menu_item_name' => 'Purchace Invoice', 'menu_item_id' => '7'), array('menu_item_name' => 'Edit Purchase', 'menu_item_id' => '8'), array('menu_item_name' => 'Purchase Return', 'menu_item_id' => '30'), array('menu_item_name' => 'Purchase Report', 'menu_item_id' => '19'), array('menu_item_name' => 'Stock Report', 'menu_item_id' => '9'), array('menu_item_name' => 'Help', 'menu_item_id' => '36')); $responce = array('status' => 'success', 'error' => '', 'data' => array('menu_list' => $menu_list)); } else { if ($user->user_type_id == 3) { $menu_list = array(array('menu_item_name' => 'Balance Sheet', 'menu_item_id' => '33'), array('menu_item_name' => 'Day End Report', 'menu_item_id' => '24'), array('menu_item_name' => 'Sales Report', 'menu_item_id' => '15'), array('menu_item_name' => 'Bank Deposit', 'menu_item_id' => '4'), array('menu_item_name' => 'Expence', 'menu_item_id' => '5'), array('menu_item_name' => 'Stock Report', 'menu_item_id' => '20'), array('menu_item_name' => 'Help', 'menu_item_id' => '37')); $responce = array('status' => 'success', 'error' => '', 'data' => array('menu_list' => $menu_list)); } else {
function get_form_html($form_id, $id, $page, $limit, $adjacents) { ob_start(); $customer = new customer(); $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $count = $customer->getCustomersCount($user->company_id); if ($page == 1) { $start = 0; $head_message = "LAST {$limit} CUSTOMERS"; } else { $start = ($page - 1) * $limit; $head_message = "CUSTOMERS {$start} TO " . ($start + $limit); } ?> <div id="head_div" style="padding: 5px 0; background-color: #ECECEC; color: #21ACD7; border-radius: 5px;margin-left: auto; text-align: center; "> <?php echo $head_message; ?> </div> <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;"> <style> div#purchace_items td{ border: 1px solid #21ACD7; } div#purchace_items tbody td{ padding: 5px 0 5px 5px; } div#purchace_items tbody td input,div#purchace_items tbody td select{ padding: 0; border: 0; margin: 0; height: 100%; width: 100%; background-color: transparent; } </style> <div style="padding: 10px 0; background-color: transparent; border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; "> <?php echo pagination($limit, $adjacents, $count, $page); ?> </div> <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> <table id="items_table" style="border-collapse: collapse; width: 100%; background-color: #fff; border-radius: 10px; color: #21ACD7;"> <thead style="text-align: center;"> <tr status="not_selected"> <td> # </td> <td> ID </td> <td> CUSTOMER NAME </td> <td style=""> CONTACT NUMBER </td> <td style=""> TOTAL PURCHACE </td> </tr> </thead> <tbody style="padding-left: 3px; text-align: center; "> <?php $customers = $customer->getCustomersPaged($user->company_id, $start, $limit); $i = $start; if ($customers == NULL || sizeof($customers) == 0) { echo '<tr><td colspan="8"> No Customer Found </td></tr>'; } else { foreach ($customers as $customer) { ?> <tr id="<?php echo $customer->id; ?> " onclick="select_row(this)" status="not_selected"> <td style="text-align: center;"> <?php echo ++$i; ?> </td> <td> <?php echo $customer->id; ?> </td> <td id="customer_name"><?php echo $customer->customer_name; ?> </td> <td id="contact_number"><?php echo $customer->contact_number; ?> </td> <td> <?php echo $customer->total_purchace_amount; ?> </td> </tr> <?php } } ?> </tbody> </table> </div> <div style="padding: 10px 0; background-color: transparent; border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; "> <?php echo pagination($limit, $adjacents, $count, $page); ?> </div> </div> <script type="text/javascript"> function select_row(row) { var j_row = $(row); if(j_row.attr('status') == 'selected'){ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); $('img#edit').css('display', 'none'); $('img#edit_fade').css('display', 'block'); $('img#delete').css('display', 'none'); $('img#delete_fade').css('display', 'block'); }else{ $('table#items_table tr').attr('status', 'not_selected'); $('table#items_table tr').css('background-color', '#FFF'); j_row.attr('status', 'selected'); j_row.css('background-color', '#C0EFFD'); $('img#edit').css('display', 'block'); $('img#edit_fade').css('display', 'none'); $('img#delete').css('display', 'block'); $('img#delete_fade').css('display', 'none'); } } function on_edit_clicked(){ var selected_row = $('tr[status="selected"]'); var customer_name = selected_row.find('td#customer_name').html(); var id = selected_row.attr('id'); var contact_number = selected_row.find('td#contact_number').html(); get_form(6, ///customer create form function (html, tools){ $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); var form = $('div#form-body').find('form.action_form'); form.attr('operation', 'update'); form.attr('customer_id', id); form.find('input#customer_name').val(customer_name); form.find('input#contact_number').val(contact_number); form.find('input[type=submit]').val('UPDATE'); $('div#head_div').html('ID : CUSTOMER-'+id); $('div#head_div').css('display', 'block'); }, function (message){ $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); } ); } function on_delete_clicked(){ var selected_row = $('tr[status="selected"]'); var id = selected_row.attr('id'); if(confirm('Are you sure you want to delete CUSTOMER-'+id+' ?' )){ var data = { form_id : 21, customer_id : id } delete_form_data(data, function(message) { get_form(21, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); $('div#form-body').empty(); alert(message); }); alert(message); }, function(message) { alert(message); }); } } function set_pagination_listener(){ $('.pagination').on('click','.page-numbers',function(e){ e.preventDefault(); var page = $(this).attr('page'); var id = 0; get_form(21, function(html, tools) { $('div#form-body').html(html); $('div#content-body-action-tools').html(tools); }, function(message) { $('font#section_heading').empty(); alert(message); },id ,page ); return false; }); } set_pagination_listener(); </script> <?php $form = ob_get_clean(); return $form; }