conn,$cfg_theme,$cfg_currency_symbol,$lang); if(!$sec->isLoggedIn()) { header ("location: ../login.php"); exit(); } //set default values, these will change if $action==update. $day=date("d"); $month=date("m"); $year=date("Y"); $today=date("Y-m-d").":".date("Y-m-d"); $yesterday=date("Y-m-d",mktime(0,0,0,$month,$day-1,$year)).":".date("Y-m-d",mktime(0,0,0,$month,$day-1,$year)); $week=date("Y-m-d",mktime(0,0,0,$month,$day-6,$year)).":".date("Y-m-d",mktime(0,0,0,$month,$day,$year)); $thismonth=date("Y-m-d",mktime(0,0,0,$month,1,$year)).":".date("Y-m-d",mktime(0,0,0,$month,$day,$year)); $lastmonth=date("Y-m-d",mktime(0,0,0,$month-1,1,$year)).":".date("Y-m-d",mktime(0,0,0,$month-1,date("t",mktime(0,0,0,$month-1,1,$year)),$year)); $thisyear=date("Y-m-d",mktime(0,0,0,1,1,$year)).":".date("Y-m-d",mktime(0,0,0,$month,$day,$year)); $alltime=date("Y-m-d",mktime(0,0,0,1,1,0000)).":".date("Y-m-d",mktime(0,0,0,$month,$day,$today)); //decides if the form will be used to update or add a user. if(isset($_GET['report'])) { $form=$_GET['report']; } $display->displayTitle("$lang->inputNeeded $form"); //if action is update, sets variables to what the current users data is. if($form=="$lang->allCustomersReport") { $f1=new form('all_customers.php','POST','customers','215',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'95'); $f1->endForm(); } elseif($form=="$lang->allItemsReport") { $f1=new form('all_items.php','POST','items','215',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'95'); $f1->endForm(); } elseif($form=="$lang->allItemsReportDateRange") { $f1=new form('all_items_date_range.php','POST','items','500',$cfg_theme,$lang); $f1->createDateSelectField(); $f1->endForm(); } elseif($form=="$lang->allBrandsReport") { $f1=new form('all_brands.php','POST','brands','215',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'95'); $f1->endForm(); } elseif($form=="$lang->allCategoriesReport") { $f1=new form('all_categories.php','POST','categories','215',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'95'); $f1->endForm(); } elseif($form=="$lang->allEmployeesReport") { $f1=new form('all_employees.php','POST','employees','215',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'95'); $f1->endForm(); } elseif($form=="$lang->brandReport") { $option_values=array(); $option_titles=array(); $brands_table=$cfg_tableprefix.'brands'; $brand_result=mysql_query("SELECT * FROM $brands_table ORDER by brand",$dbf->conn); if(isset($_GET['brand_search'])) { $search=$_GET['brand_search']; $brand_result=mysql_query("SELECT * FROM $brands_table WHERE brand like \"%$search%\" ORDER by brand",$dbf->conn); } if(mysql_num_rows($brand_result)>0) { while($row=mysql_fetch_assoc($brand_result)) { $option_values[]=$row['id']; $option_titles[]=$row['brand']; } } else { $option_values[]=$search.$lang->notFound; $option_titles[]='"'.$search.'"'.' '.$lang->notFound; } echo "
$lang->findBrand: brandReport value='Go'>
"; $f1=new form('brand.php','POST','brand','450',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'150'); $f1->createSelectField("$lang->selectBrand",'selected_brand',$option_values,$option_titles,'150'); $f1->endForm(); } elseif($form=="$lang->categoryReport") { $option_values=array(); $option_titles=array(); $categories_table=$cfg_tableprefix.'categories'; $category_result=mysql_query("SELECT * FROM $categories_table ORDER by category",$dbf->conn); if(isset($_GET['category_search'])) { $search=$_GET['category_search']; $category_result=mysql_query("SELECT * FROM $categories_table WHERE category like \"%$search%\" ORDER by category",$dbf->conn); } if(mysql_num_rows($category_result)>0) { while($row=mysql_fetch_assoc($category_result)) { $option_values[]=$row['id']; $option_titles[]=$row['category']; } } else { $option_values[]=$search.$lang->notFound; $option_titles[]='"'.$search.'"'.' '.$lang->notFound; } echo "
$lang->findCategory: categoryReport value='Go'>
"; $f1=new form('category.php','POST','category','450',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'150'); $f1->createSelectField("$lang->selectCategory",'selected_category',$option_values,$option_titles,'150'); $f1->endForm(); } elseif($form=="$lang->taxReport") { $option_values=array(); $option_titles=array(); $sales_items_table=$cfg_tableprefix.'sales_items'; $tax_result=mysql_query("SELECT DISTINCT item_tax_percent FROM $sales_items_table ORDER by item_tax_percent DESC",$dbf->conn); if(mysql_num_rows($tax_result)>0) { while($row=mysql_fetch_assoc($tax_result)) { $option_values[]=$row['item_tax_percent']; $option_titles[]=$row['item_tax_percent'].'%'; } } else { $option_values[]=$search.$lang->notFound; $option_titles[]='"'.$search.'"'.' '.$lang->notFound; } echo "
"; $f1=new form('tax.php','POST','tax','450',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'150'); $f1->createSelectField("$lang->selectTax %",'selected_tax',$option_values,$option_titles,'150'); $f1->endForm(); } elseif($form=="$lang->customerReport") { $option_values=array(); $option_titles=array(); $customers_table=$cfg_tableprefix.'customers'; $customer_result=mysql_query("SELECT first_name,last_name,id FROM $customers_table ORDER by last_name",$dbf->conn); if(isset($_GET['customer_search'])) { $search=$_GET['customer_search']; $customer_result=mysql_query("SELECT first_name,last_name,id FROM $customers_table WHERE last_name like \"%$search%\" or first_name like \"%$search%\" ORDER by last_name",$dbf->conn); } if(mysql_num_rows($customer_result)>0) { while($row=mysql_fetch_assoc($customer_result)) { $option_values[]=$row['id']; $option_titles[]=$row['last_name'].', '.$row['first_name']; } } else { $option_values[]=$search.$lang->notFound; $option_titles[]='"'.$search.'"'.' '.$lang->notFound; } echo "
$lang->findCustomer: customerReport value='Go'>
"; $f1=new form('customer.php','POST','customer','450',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'150'); $f1->createSelectField("$lang->selectCustomer",'selected_customer',$option_values,$option_titles,'150'); $f1->endForm(); } elseif($form=="$lang->customerReportDateRange") { $option_values=array(); $option_titles=array(); $customers_table=$cfg_tableprefix.'customers'; $customer_result=mysql_query("SELECT first_name,last_name,account_number,id FROM $customers_table ORDER by last_name",$dbf->conn); if(isset($_GET['customer_search'])) { $search=$_GET['customer_search']; $customer_result=mysql_query("SELECT first_name,last_name,account_number,id FROM $customers_table WHERE last_name like \"%$search%\" or first_name like \"%$search%\" or account_number like \"%$search%\" ORDER by last_name",$dbf->conn); } if(mysql_num_rows($customer_result)>0) { while($row=mysql_fetch_assoc($customer_result)) { $option_values[]=$row['id']; $option_titles[]=$row['last_name'].', '.$row['first_name'].' ('.$row['account_number'].')'; } } else { $option_values[]=$search.$lang->notFound; $option_titles[]='"'.$search.'"'.' '.$lang->notFound; } echo "
$lang->findCustomer: customerReportDateRange value='Go'>
"; $f1=new form('customer_date_range.php','POST','customer','500',$cfg_theme,$lang); $f1->createDateSelectField(); $f1->formBreak('500',$cfg_theme); $f1->createSelectField("$lang->selectCustomer",'selected_customer',$option_values,$option_titles,'130'); $f1->endForm(); } elseif($form=="$lang->itemReport") { $option_values=array(); $option_titles=array(); $items_table=$cfg_tableprefix.'items'; $item_result=mysql_query("SELECT item_name,id FROM $items_table ORDER by item_name",$dbf->conn); if(isset($_GET['item_search'])) { $search=$_GET['item_search']; $item_result=mysql_query("SELECT item_name,id FROM $items_table WHERE item_name like \"%$search%\" ORDER by item_name",$dbf->conn); } if(mysql_num_rows($item_result)>0) { while($row=mysql_fetch_assoc($item_result)) { $option_values[]=$row['id']; $option_titles[]=$row['item_name']; } } else { $option_values[]=$search.$lang->notFound; $option_titles[]='"'.$search.'"'.' '.$lang->notFound; } echo "
$lang->findItem: itemReport value='Go'>
"; $f1=new form('item.php','POST','item','450',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'150'); $f1->createSelectField("$lang->selectItem",'selected_item',$option_values,$option_titles,'150'); $f1->endForm(); } elseif($form=="$lang->itemReportDateRange") { $option_values=array(); $option_titles=array(); $items_table=$cfg_tableprefix.'items'; $item_result=mysql_query("SELECT item_name,item_number,id FROM $items_table ORDER by item_name",$dbf->conn); if(isset($_GET['item_search'])) { $search=$_GET['item_search']; $item_result=mysql_query("SELECT item_name,item_number,id FROM $items_table WHERE item_name like \"%$search%\" or item_number like \"%$search%\" ORDER by item_name",$dbf->conn); } if(mysql_num_rows($item_result)>0) { while($row=mysql_fetch_assoc($item_result)) { $option_values[]=$row['id']; $option_titles[]=$row['item_name'].' ['.$row['item_number'].']'; } } else { $option_values[]=$search.$lang->notFound; $option_titles[]='"'.$search.'"'.' '.$lang->notFound; } echo "
$lang->findItem:
"; $f1=new form('item_date_range.php','POST','item','500',$cfg_theme,$lang); $f1->createDateSelectField(); $f1->formBreak('500',$cfg_theme); $f1->createSelectField("$lang->selectItem",'selected_item',$option_values,$option_titles,'130'); $f1->endForm(); } elseif($form=="$lang->employeeReport") { $option_values=array(); $option_titles=array(); $employees_table=$cfg_tableprefix.'users'; $employee_result=mysql_query("SELECT first_name,last_name,id FROM $employees_table ORDER by last_name",$dbf->conn); if(isset($_GET['employee_search'])) { $search=$_GET['employee_search']; $employee_result=mysql_query("SELECT first_name,last_name,id FROM $employees_table WHERE last_name like \"%$search%\" or first_name like \"%$search%\" ORDER by last_name",$dbf->conn); } if(mysql_num_rows($employee_result)>0) { while($row=mysql_fetch_assoc($employee_result)) { $option_values[]=$row['id']; $option_titles[]=$row['last_name'].', '.$row['first_name']; } } else { $option_values[]=$search.$lang->notFound; $option_titles[]='"'.$search.'"'.' '.$lang->notFound; } echo "
$lang->findEmployee: employeeReport value='Go'>
"; $f1=new form('employee.php','POST','employee','450',$cfg_theme,$lang); $option_values2=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles2=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1->createSelectField("$lang->dateRange",'date_range',$option_values2,$option_titles2,'150'); $f1->createSelectField("$lang->selectEmployee",'selected_employee',$option_values,$option_titles,'150'); $f1->endForm(); } elseif($form=="$lang->dateRangeReport") { $f1=new form('date_range.php','POST','customer','500',$cfg_theme,$lang); $f1->createDateSelectField(); $f1->endForm(); } elseif($form=="$lang->profitReport") { $option_values=array("$today","$yesterday","$week","$thismonth","$lastmonth","$thisyear","$alltime"); $option_titles=array("$lang->today","$lang->yesterday","$lang->last7days","$lang->thisMonth","$lang->lastMonth","$lang->thisYear","$lang->allTime"); $f1=new form('profit.php','POST','profit','200',$cfg_theme,$lang); $f1->createSelectField("$lang->dateRange",'date_range',$option_values,$option_titles,'200'); $f1->endForm(); } $dbf->closeDBlink(); ?>