error_reporting(E_ERROR | E_WARNING | E_PARSE); $start_memory = memory_get_usage(); require("../config/config.php"); ob_start(); if($_POST['login'] == "Login") { $context['email'] = $_POST['email']; $context['password'] = $_POST['password']; $context['db_name'] =& $db_name; $context['db_user'] =& $db_user; $context['db_password'] =& $db_password; $context['db_client'] =& $db_client; $context['db_client_accounts'] =& $db_client_accounts; $context['db_client_settings'] =& $db_client_settings; $context['db_client_status'] =& $db_client_status; $context['db_global'] =& $db_global; $context['db_global_status'] =& $db_global_status; $context['db_client_status_name'] =& $db_client_status_name; $context['db_client_user'] =& $db_client_user; $context['db_client_password'] =& $db_client_password; $returned_values = common_login::login_client($context); $_SESSION = $returned_values; $pass = $returned_values['pass']; $error_msg = $returned_values['error_msg']; if($pass == "true") redirect::set($_SESSION['user']['default_landing_page']); } $page = (!empty($_GET['page'])) ? $_GET['page'] : $_SESSION['user']['default_landing_page']; $_GET['page'] = $page; $user_type = $_SESSION['user']['user_type']; mb_language('uni'); mb_internal_encoding('UTF-8'); if(!empty($user_type)) { date_default_timezone_set($_SESSION['time_zone']); $browser = check_browser::get_this_broswer(); //$browser = "ipad"; $login_user = $_SESSION['user']['group_id']; //if($browser == "ipad") if( ($login_user == 40 ) || ($login_user == 41 ) ) require("templates_tablet/".SITE_TEMPLATE."/template.php"); else require("templates/".SITE_TEMPLATE."/template.php"); $conn_init = database::init(DB_NAME,DB_USER,DB_PASSWORD); list($database,$db_client) = database::init_current_client($conn_init,DB_CLIENT_ACCOUNTS,DB_CLIENT_USER,DB_CLIENT_PASSWORD); $database->LogSQL(); $context['database'] =& $database; $context['user_type'] =& $user_type; $context['page'] =& $page; $context['root'] = ROOT_DIR; /*csv export put here to prevent all client side code*/ if($page=="payroll_jobs_update"&& ($_GET['Submit']=="Material Report"||$_GET['Submit']=="Labour Report")) { $context = array( "start_date" => $_GET['start_date'], "end_date" => $_GET['end_date'], ); $context['list_config'] = array( "method" => $_GET['method'], "order" => $_GET['order'], "avail_edit" => false, "avail_status" => false, "link_view" => "jobs_details", "link_edit" => "jobs_edit", "show_search" => true, "show_pagination" => false, "sortable" => true ); $context['columns']["id"] = array("title" => "Job ID","view" => true); $context['columns']["quote_id"] = array("title" => "Quote ID"); $context['columns']["job_name"] = array("title" => "Job Name"); $context['columns']["labours"] = array("title" => "Labour"); /*Kai 23-10-2012 added*/ //$context['columns']["total"] = array("title" => "Acutal Cost"); $context['columns']["current_materials"] = array("title" => "Materials"); $obj = new list_jobs_updates($context); $obj->get_data(); $csv_raw_array = $obj->final_results; $report = new form_reports_staff_productivity($context); if($_GET['Submit']=="Material Report") { $header_array = array('Journal Number','Date','Memo','Item Number','Location', 'Quantity','Unit Cost','Amount','Account','Job', 'Allocation Memo','Category','Job Allocation Amount','Job Allocation Percent','Serial Number'); //date("Ymdhi") $filename = "Material_".date("d-m-Y",strtotime(dates::change_to_sql($_GET['start_date'])))."_to_".date("d-m-Y",strtotime(dates::change_to_sql($_GET['end_date']))).".csv"; $report->download_csv_from_header($filename); if($csv_raw_array){ $array = null; $i = 0; $job_amount_arr = array(); foreach($csv_raw_array as $index=>$arr){ if($arr['id']){ foreach($arr['materials'] as $material) { if($material['item']=='12345') { continue; } $array[$i]['journal_number']= 'IJ001284'; $array[$i]['date']=$material['date']; $array[$i]['memo']='stock used'; $array[$i]['item_number']=$material['item']; $array[$i]['location']='Location1'; $array[$i]['quantity']=0-$material['quantity']; $array[$i]['cost']= money_format('$%i', $material['cost']); $array[$i]['amount']=money_format('-$%i', $material['cost']*$material['quantity']); $array[$i]['account']='51140'; $array[$i]['job_id']=$arr['id']; $array[$i]['allocate_memo']=$arr['id']; $array[$i]['category']=''; $array[$i]['job_allocation_amount']=''; $array[$i]['job_allocation_percent']='0%'; $array[$i]['serial_number']=''; $i++; $job_amount_arr[$arr['id']] +=$material['cost']*$material['quantity']; $temp_amount = 0; } /*$array[]['quote_id']=$arr['quote_id']; $array[]['job_name']=$arr['job_name']; $array[]['labours']=$arr['labours']; $array[]['csv_materials']=$arr['csv_materials'];*/ } } foreach($array as $i=>$arr){ $array[$i]['job_allocation_amount']=money_format( '-$%i',$job_amount_arr[$arr['job_id']] ); } echo $report->array2csv($header_array,$array); }else{ echo "No Record."; } } else { $header_array = array('Journal Number','Date','Memo','GST [BAS] Reporting','Inclusive', 'Account Number','Debit Ex-Tax Amount','Debit Inc-Tax Amount','Credit Ex-Tax Amount','Credit Inc-Tax Amount', 'Job','Tax Code','Non-GST/LCT Amount','Tax Amount','LCT Amount', 'Import Duty Amount','Currency Code','Exchange Rate','Allocation Memo','Category', 'Department ID','Department Allocation Amount','Department Allocation Percent', 'Job Allocation Amount','Job Allocation Percent'); $filename = "Labour_".date("d-m-Y",strtotime(dates::change_to_sql($_GET['start_date'])))."_to_".date("d-m-Y",strtotime(dates::change_to_sql($_GET['end_date']))).".csv"; $report->download_csv_from_header($filename); if($csv_raw_array){ $array = null; $i = $total_amount = 0; $rate = common_job_trackings::get_installation_hourly_rate(); foreach($csv_raw_array as $index=>$arr){ if($arr['id']){ $array[$i]['journal_number']= 'GJ000286'; $array[$i]['date']=$_GET['start_date']; $array[$i]['memo']='update jobs'; $array[$i]['gst_reporting']='P'; $array[$i]['inclusive']='X'; $array[$i]['account']='52000'; $charge = $rate*$arr['labours']; $total_amount +=$charge; $charge = money_format('$%i', $charge); $array[$i]['debit_ex_amount']= $charge; $array[$i]['debit_inc_amount']= $charge; $array[$i]['credit_ex_amount']= ''; $array[$i]['credit_inc_amount']= ''; $array[$i]['job']=$arr['id']; $array[$i]['tax_code']='N-T'; $array[$i]['nongst_amount']='$0.00'; $array[$i]['tax_amount']='$0.00'; $array[$i]['lct_amount']='$0.00'; $array[$i]['import_duty_amount']='$0.00'; $array[$i]['currency_code']=''; $array[$i]['exchange_rate']=''; $array[$i]['allocation_memo']=''; $array[$i]['category']=''; $array[$i]['department_id']=''; $array[$i]['depart_allocation_amount']=''; $array[$i]['depart_allocation_percent']=''; $array[$i]['job_allocation_amount']=$charge; $array[$i]['job_allocation_percent']='0%'; $i++; /*$array[]['quote_id']=$arr['quote_id']; $array[]['job_name']=$arr['job_name']; $array[]['labours']=$arr['labours']; $array[]['csv_materials']=$arr['csv_materials'];*/ } } $array[$i]['journal_number']= 'GJ000286'; $array[$i]['date']=$_GET['start_date']; $array[$i]['memo']='update jobs'; $array[$i]['gst_reporting']='P'; $array[$i]['inclusive']='X'; $array[$i]['account']='52000'; $array[$i]['debit_ex_amount']= ''; $array[$i]['debit_inc_amount']= ''; $total_amount = money_format('$%i', $total_amount); $array[$i]['credit_ex_amount']= $total_amount; $array[$i]['credit_inc_amount']= $total_amount; $array[$i]['job']=''; $array[$i]['tax_code']='N-T'; $array[$i]['nongst_amount']='$0.00'; $array[$i]['tax_amount']='$0.00'; $array[$i]['lct_amount']='$0.00'; $array[$i]['import_duty_amount']='$0.00'; $array[$i]['currency_code']=''; $array[$i]['exchange_rate']=''; $array[$i]['allocation_memo']=''; $array[$i]['category']=''; $array[$i]['department_id']=''; $array[$i]['depart_allocation_amount']=''; $array[$i]['depart_allocation_percent']=''; $array[$i]['job_allocation_amount']=''; $array[$i]['job_allocation_percent']=''; echo $report->array2csv($header_array,$array); }else{ echo "No Record."; } } }else{ template::headers($context); template::contents($context); template::footer($context); } /* $mem_usage = memory_get_usage() - $start_memory; $mem_usage = perform::mem_convert($mem_usage); $size_of_session_estimate = perform::mem_convert(strlen( serialize( $_SESSION ) )); $perf = NewPerfMonitor($database); echo $perf->InvalidSQL(); echo $perf->SuspiciousSQL(); echo $perf->ExpensiveSQL(); echo $perf->HealthCheck(); $sql = "TRUNCATE TABLE `adodb_logsql`"; $database->query($sql); */ } else { $url = $_SERVER['HTTP_HOST']; $db_client = explode(".",$url); $site_template_login = SITE_TEMPLATE_LOGIN; ?>
Please check your email
An email has been sent to all contact emails associated with your account, '.$_POST['email'].'. This email describes how to get your new password.
Please be patient; the delivery of email may be delayed. Remember to confirm that the email above is correct and to check your junk or spam folder or filter if you do not receive this email.
';
message_box::show_box($context);
}
else if($status == "failed")
{
$context['header'] = "Failed to send email!";
$context['message'] = $returned_values['reason'];
message_box::show_box($context);
}
}
else
{
$filename = "templates_login/".$site_template_login."/forgot_password.php";
require($filename);
}
}
else if($page == "retrieve")
{
if($_POST['reset'] == "Reset")
{
$new_password = $_POST['new_password'];
$confirm_password = $_POST['confirm_password'];
$new_password_check = md5($new_password);
$confirm_password_check = md5($confirm_password);
$context['hash'] = $_GET['user'];
if(empty($new_password) || empty($confirm_password))
{
$context['error'] = "Please check that you have filled out the form!";
$filename = "templates_login/".$site_template_login."/retrieve_password.php";
require($filename);
retrieve_password::retrieve_form($context);
}
else if($new_password_check != $confirm_password_check)
{
$context['error'] = "The password are not identical, please check the form!";
$filename = "templates_login/".$site_template_login."/retrieve_password.php";
require($filename);
retrieve_password::retrieve_form($context);
}
else
{
$hash = $_GET['user'];
$url = $_SERVER['SERVER_NAME'];
$db_client = explode(".",$url);
$database = database::init($db_name,$db_user,$db_password);
// $database->debug = true;
$filename = "templates_login/".$site_template_login."/message_box.php";
require($filename);
$hasher = new PasswordHash(8, FALSE);
$new_password = $hasher->HashPassword($new_password);
// $database->debug = true;
$update = "
update users
SET
password = '$new_password'
WHERE hash = '$hash'";
$query = $database->query($update);
if(!$query)
{
$context['header'] = "Password failed to change!";
$context['message'] = "
Your password has been failed to change!!
Your password has been successfully changed!!