From 2139c659670292c1dfc6b893b01c444e13c4aee8 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 24 Sep 2015 17:25:43 +0300 Subject: [PATCH] ADD New number to appointment contact in admin mode multiple 'undefined variable' fixes --- admin/displayappointments.php | 186 +++++++++++++++++++++------------- 1 file changed, 116 insertions(+), 70 deletions(-) diff --git a/admin/displayappointments.php b/admin/displayappointments.php index 5075b583..db5dd924 100644 --- a/admin/displayappointments.php +++ b/admin/displayappointments.php @@ -58,19 +58,27 @@ $js_foot = array( "../js/bootstrap-confirmation.js", "../js/custom.js" ); - + //create new or update appointment if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['update'])) { $start = $db->qstr($_GET['start']); $end = $db->qstr($_GET['end']); - $contact_phone_id = bigintval($_GET['contact_phone_id']); + $case_id = bigintval($_GET['case_id']); $respondent_id = bigintval($_GET['respondent_id']); $require_operator_id = "NULL"; if ($_GET['require_operator_id'] > 1) $require_operator_id = bigintval($_GET['require_operator_id']); - if ($_GET['new'] == 'create'){ - $case_id = bigintval($_GET['case_id']); + //* add new number to db + if ( isset($_GET['addphonenumber']) && !empty($_GET['addphonenumber'])){ + add_contact_phone($case_id,$_GET['addphonenumber']); + $contact_phone_id = $db->Insert_ID(); + } + else { + $contact_phone_id = bigintval($_GET['contact_phone_id']); + } + + if (isset($_GET['new']) && $_GET['new'] == 'create'){ $operator_id = get_operator_id(); if ($operator_id == false) die(); $sql = "SELECT Time_zone_name FROM respondent WHERE respondent_id = '$respondent_id'"; @@ -104,14 +112,15 @@ if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['update'])) $db->Execute($sql); } - unset ($_GET['start'],$_GET['end'],$_GET['appointment_id'],$_GET['case_id'],$_GET['new'],$_GET['update']); + unset ($_GET['start'],$_GET['end'],$_GET['new'],$_GET['update'],$_GET['appointment_id'],$_GET['case_id'],$_GET['addphonenumber']); // } if ( (isset($_GET['appointment_id']) && isset($_GET['case_id'])) ||(isset($_GET['new']) && isset($_GET['case_id']))) { - $appointment_id = bigintval($_GET['appointment_id']); - $case_id = bigintval($_GET['case_id']); + if (isset($_GET['appointment_id'])) $appointment_id = bigintval($_GET['appointment_id']); else $appointment_id = ""; + if (isset($_GET['case_id'])) $case_id = bigintval($_GET['case_id']); + $require_operator_id = "NULL"; if (isset($_GET['delete'])) { @@ -121,27 +130,61 @@ if ( (isset($_GET['appointment_id']) && isset($_GET['case_id'])) ||(isset($_GET[ xhtml_head(T_("Now modify case outcome"),true,$css,$js_head); - print "

" . T_("The appointment has been deleted. Now you must modify the case outcome") . "

+ print "

" . T_("The appointment has been deleted. Now you must modify the case outcome") . "

" . T_("Modify case outcome") . "
"; } else { - //Display an edit form + $lang = DEFAULT_LOCALE ; + + $sql = "SELECT CONVERT_TZ(NOW(),'SYSTEM',r.Time_zone_name) as startdate, + CONVERT_TZ(DATE_ADD(NOW(), INTERVAL 10 YEAR),'SYSTEM',r.Time_zone_name) as enddate, + r.respondent_id, ca.contact_phone_id + FROM `case` as c, `respondent` as r, `call` as ca + WHERE c.case_id = '$case_id' + AND r.case_id = c.case_id + AND c.last_call_id = ca.call_id"; + $rs = $db->GetRow($sql); - if ($_GET['new'] == 'new'){$title = T_("Create NEW appointment");} else{$title = T_("Edit appointment"); $subtitle = "ID " . $appointment_id;} + $startdate = $rs['startdate']; + $enddate = $rs['enddate']; + $respondent_id = $rs['respondent_id']; + if (!isset($contact_phone_id)) $contact_phone_id = $rs['contact_phone_id']; + + if (isset($_GET['new']) && $_GET['new'] == 'new'){ + $title = T_("Create NEW appointment"); + $subtitle =""; + $start = $startdate; + $end = $enddate; + $rtz = $_GET['rtz']; + } + if (isset($_GET['appointment_id'])) { + $title = T_("Edit appointment"); + $subtitle = "ID " . $appointment_id; + + $sql = "SELECT a.contact_phone_id,a.call_attempt_id, CONVERT_TZ(a.start,'UTC',r.Time_zone_name) as `start`, CONVERT_TZ(a.end,'UTC',r.Time_zone_name) as `end`, a.respondent_id, a.require_operator_id, r.Time_zone_name as rtz + FROM `appointment` as a, respondent as r + WHERE a.appointment_id = '$appointment_id' + AND a.case_id = '$case_id' + AND r.respondent_id = a.respondent_id"; + + $rs = $db->GetRow($sql); + + if (!empty($rs)){ + $respondent_id = $rs['respondent_id']; + $contact_phone_id = $rs['contact_phone_id']; + $require_operator_id = $rs['require_operator_id']; + $start = $rs['start']; + $end = $rs['end']; + $rtz = $rs['rtz']; + } + else die(T_("ERROR in DB records, Check tables 'appointment' and 'respondent' and Time zone settings")); + } + + //Display an edit form xhtml_head($title,true,$css,$js_head,false,false,false,$subtitle); - $lang = DEFAULT_LOCALE; - - $sql = "SELECT CONVERT_TZ(NOW(),'SYSTEM',r.Time_zone_name) as startdate, CONVERT_TZ(DATE_ADD(NOW(), INTERVAL 10 YEAR),'SYSTEM',r.Time_zone_name) as enddate - FROM `case` as c, `respondent` as r - WHERE c.case_id = '$case_id' AND r.case_id = c.case_id"; - - $rs = $db->GetRow($sql); - $startdate = $rs['startdate']; - $enddate = $rs['enddate']; - print ""; - if ($_GET['new'] =='new'){ - $start = $startdate; - $end = $enddate; - $rtz = $_GET['rtz']; - } - if (isset($_GET['appointment_id'])) { + print "
"; + print ""; + + display_chooser($db->GetAll("SELECT respondent_id as value, CONCAT(firstName,' ',lastName) as description, + CASE when respondent_id = '$respondent_id' THEN 'selected=\'selected\'' ELSE '' END as selected + FROM respondent + WHERE case_id = '$case_id'"),"respondent_id","respondent_id",false,false,false,true,false,true,"pull-left"); - $sql = "SELECT a.contact_phone_id,a.call_attempt_id, CONVERT_TZ(a.start,'UTC',r.Time_zone_name) as `start`, CONVERT_TZ(a.end,'UTC',r.Time_zone_name) as `end`, a.respondent_id, a.require_operator_id, r.Time_zone_name as rtz - FROM `appointment` as a, respondent as r - WHERE a.appointment_id = '$appointment_id' - AND a.case_id = '$case_id' - AND r.respondent_id = a.respondent_id"; - - $rs = $db->GetRow($sql); - - if (!empty($rs)){ - $respondent_id = $rs['respondent_id']; - $contact_phone_id = $rs['contact_phone_id']; - $require_operator_id = $rs['require_operator_id']; - $start = $rs['start']; - $end = $rs['end']; - $rtz = $rs['rtz']; - } - } - print ""; - print ""; + print "

"; - display_chooser($db->GetAll("SELECT respondent_id as value, CONCAT(firstName,' ',lastName) as description, - CASE when respondent_id = '$respondent_id' THEN 'selected=\'selected\'' ELSE '' END as selected - FROM respondent - WHERE case_id = '$case_id'"),"respondent_id","respondent_id",false,false,false,true,false,true,"pull-left"); + $sql = "SELECT contact_phone_id as value, phone as description, + CASE when contact_phone_id = '$contact_phone_id' THEN 'selected=\'selected\'' ELSE '' END as selected + FROM contact_phone + WHERE case_id = '$case_id'"; + $rs = $db->GetAll($sql); + +//* added option to add new number + print "
"; - print "

"; - display_chooser($db->GetAll("SELECT contact_phone_id as value, phone as description, - CASE when contact_phone_id = '$contact_phone_id' THEN 'selected=\'selected\'' ELSE '' END as selected - FROM contact_phone - WHERE case_id = '$case_id'"), - "contact_phone_id","contact_phone_id",false,false,false,true,false,true,"pull-left"); - - print "

". T_("ATTENTION! Keep in mind that you're setting 'Start' & 'End' appoinment times in RESPONDENT LOCAL TIME !!!") . "
"; + print ""; +//*end option + + print "

". T_("ATTENTION! Keep in mind that you're setting 'Start' & 'End' appoinment times in RESPONDENT LOCAL TIME !!!") . "
"; + date_default_timezone_set($rtz); - print " -

" . $rtz . "

+ + print " +

" . $rtz . "

"; - print "

+ print "

"; - print "

+ print "

"; - print "

"; + print "

"; $ops = $db->GetAll("SELECT o.operator_id as value, CONCAT(o.firstName, ' ', o.lastName) as description, CASE WHEN o.operator_id = '$require_operator_id' THEN 'selected=\'selected\'' ELSE '' END as selected @@ -225,17 +263,25 @@ if ( (isset($_GET['appointment_id']) && isset($_GET['case_id'])) ||(isset($_GET[ } } array_unshift($ops,array('value'=>0,'description'=>T_("Any operator"),'selected'=>$selected)); - display_chooser($ops,"require_operator_id","require_operator_id",false,false,false,true,false,true,"pull-left"); - print ""; - if ($_GET['new'] == 'new') { print "";} + display_chooser($ops,"require_operator_id","require_operator_id",false,false,false,true,false,true,"pull-left"); + + print " + + "; + + if (isset($_GET['new']) && $_GET['new'] == 'new') { + print ""; + } print "


- "; + "; - print "
"; + print "
+ +
"; - print ""; + print ""; print "
"; }