Info pour fibre:\n$tech_fibre\nOLT: {$row_fibre_info['info_connect']}\nVille: {$row_fibre_info['ville']}\nRue: {$row_fibre_info['rue']}\nCivique: {$row_fibre_info['terrain']}
";
//ticket tech pour installer le boitier
if($row_fibre_info['boitier_pas_install'] == 1){
$date_boitier = date('U',strtotime('+1 day'));
$q_ticket_boitier = "INSERT INTO `ticket` (`account_id`, `subject`, `dept_id`, `open_by`, `assign_to`, `status`, `date_create`, `last_update`, `due_date`) VALUES ";
$q_ticket_boitier .= "('{$_POST['account_id']}', '{$row_fibre_info['ville']} | Installation boitier', '27', '$userid', '3301', 'open', $time_now, $time_now, $date_boitier)";
$sql->query($q_ticket_boitier);
$ticket_boitier = $sql->insert_id;
$msg_boitier = "Installation pour un client au {$row_fibre_info['terrain']} {$row_fibre_info['rue']} {$row_fibre_info['ville']} prevu pour le " . date('d-m-Y', $date);
$msg_boitier .= "\nLe boitier a besoin d'être fait au préalable.\nNe pas oublier de mettre a jour la map pour les adresses affectées par cette intervention";
$msg_boitier = $sql->real_escape_string($msg_boitier);
$q_boitier_msg = "INSERT INTO `ticket_msg` (`ticket_id`, `staff_id`, `msg`, `date_orig`) VALUES ('$ticket_boitier','$userid','$msg_boitier','$time_now');";
$sql->query($q_boitier_msg);
}
}
$ticket_msg .= $info_fibre;
$result_aID = $sql->query("SHOW TABLE STATUS LIKE 'ticket';");
$row_aID = $result_aID->fetch_array();
$ticket_id = $row_aID['Auto_increment'];
$q_follow = "SELECT * FROM `ticket_dept` WHERE `id` = $ticket_dept";
$res_follow = $sql->query($q_follow);
$row_follow = $res_follow->fetch_assoc();
if($row_follow['default_follow'] == 0)
$follow = "[]";
else{
$thisFollower[$row_follow['default_follow']]['child'] = 0;
$follow = json_encode($thisFollower);
}
if($_POST['fibre'] > 0){
$q_ticket_fact = "INSERT INTO `ticket` (`account_id`, `subject`, `dept_id`, `open_by`, `assign_to`, `status`, `date_create`, `last_update`) VALUES ";
$q_ticket_fact .= "('{$_POST['account_id']}', 'validation paiement installation', '2', '$userid', '0', 'open', $time_now, $time_now)";
$sql->query($q_ticket_fact);
$ticket_fact = $sql->insert_id;
$msg_fact = $sql->real_escape_string("Fermer le ticket pour activer le ticket d'installation");
$q_fac_msg = "INSERT INTO `ticket_msg` (`ticket_id`, `staff_id`, `msg`, `date_orig`) VALUES ('$ticket_fact','$userid','$msg_fact','$time_now');";
$sql->query($q_fac_msg);
$q_ticket = "INSERT INTO `$mydbName`.`ticket` (`account_id`, `subject`, `dept_id`, `open_by`, `assign_to`, `status`, `waiting_for`, `parent`, `due_date`, `due_time`, `date_create`, `last_update`, `wizard`, `wizard_fibre`, `bon_id`, `followed_by`) VALUES ";
$q_ticket .= "('{$_POST['account_id']}', '$subject', '$ticket_dept', '$userid', '$ticket_assign', 'pending', '$ticket_fact', '$ticket_fact', '$date', '{$_POST['date_time']}', $time_now, $time_now, '$service_list', '$wiz_fibre', '$bon_id', '$follow')";
}
else{
$q_ticket = "INSERT INTO `$mydbName`.`ticket` (`account_id`, `subject`, `dept_id`, `open_by`, `assign_to`, `status`, `due_date`, `due_time`, `date_create`, `last_update`, `wizard`, `wizard_fibre`, `bon_id`, `followed_by`) VALUES ";
$q_ticket .= "('{$_POST['account_id']}', '$subject', '$ticket_dept', '$userid', '$ticket_assign', 'open', '$date', '{$_POST['date_time']}', $time_now, $time_now, '$service_list', '$wiz_fibre', '$bon_id', '$follow')";
}
//$q_ticket = "INSERT INTO `$mydbName`.`ticket` (`account_id`, `subject`, `dept_id`, `open_by`, `assign_to`, `status`, `due_date`, `due_time`, `date_create`, `last_update`, `wizard`, `wizard_fibre`, `bon_id`, `followed_by`) VALUES ";
//$q_ticket .= "('{$_POST['account_id']}', '$subject', '$ticket_dept', '$userid', '$ticket_assign', 'open', '$date', '{$_POST['date_time']}', $time_now, $time_now, '$service_list', '$wiz_fibre', '$bon_id', '$follow')";
$sql->query($q_ticket);
$ticket_id = $sql->insert_id;
$ticket_msg = change_quote($ticket_msg);
$q_ticket_msg = "INSERT INTO `$mydbName`.`ticket_msg` (`ticket_id`, `staff_id`, `msg`, `date_orig`, `unread_csv`, `public`) VALUES ('$ticket_id','$userid','$ticket_msg','$time_now','$unread_csv','0')";
$sql->query($q_ticket_msg);
if(isset($_POST['chk_phone'])){
$result_aID = $sql->query("SHOW TABLE STATUS LIKE 'ticket';");
$row_aID = $result_aID->fetch_array();
$ticket_id_t = $row_aID['Auto_increment'];
$q_ticket = "INSERT INTO `ticket` (`parent`, `account_id`, `subject`, `dept_id`, `open_by`, `assign_to`, `status`, `due_date`, `due_time`, `date_create`, `last_update`, `wizard`) VALUES ";
$q_ticket .= "('$ticket_id','{$_POST['account_id']}', 'Configuration boitier tel', '23', '$userid', '4661', 'open', '$date', '{$_POST['date_time']}', $time_now, $time_now, '$service_list')";
$sql->query($q_ticket);
$ticket_id_t = $sql->insert_id;
$q_ticket_msg = "INSERT INTO `ticket_msg` (`ticket_id`, `staff_id`, `msg`, `date_orig`, `unread_csv`, `public`) VALUES ('$ticket_id_t','$userid','voir parent','$time_now','$unread_csv','0')";
$sql->query($q_ticket_msg);
}
if(isset($_FILES['uploadedfile'])){
$base_path = "uploads/ticket/$ticket_id/";
if(!is_dir("uploads/ticket/$ticket_id")) mkdir("uploads/ticket/$ticket_id");
$q = "SELECT `attachment_ext` FROM `compta_setup`";
$res = $sql->query($q);
$list_attachement = $res->fetch_array();
$list_attachement = $list_attachement[0];
for($i=0; $i < count($_FILES['uploadedfile']['name']); $i++){
$filename = basename( $_FILES['uploadedfile']['name'][$i]);
$filename = getRewriteString($filename);
$target_path = $base_path . $filename;
$tmp = explode('.',$target_path);
$ext = strtolower($tmp[count($tmp)-1]);
if(stripos($list_attachement,$ext) !== false){
copy($_FILES['uploadedfile']['tmp_name'][$i], $target_path);
}
}
}
$log_cf = file_get_contents('/targo/facturation/logs/log');
$log_cf .= "[" . date('D d M Y H:i:s') . "] [ACCOUNT : WIZARD] <$staff_username> Wizard pour l'adresse {$_POST['delivery_id']} - ticket #$ticket_id \n";
file_put_contents('/targo/facturation/logs/log', $log_cf);
$_POST['wiz_account'] = $_POST['account_id'];
$_POST['wiz_delivery'] = $_POST['delivery_id'];
echo "";
}
$account_id = $_POST['wiz_account'];
$delivery_id = $_POST['wiz_delivery'];
$q_account = "SELECT * FROM `$mydbName`.`account` WHERE `id` = '$account_id'";
$res_account = $sql->query($q_account);
$row_account = $res_account->fetch_array();
$q_delivery = "SELECT * FROM `$mydbName`.`delivery` WHERE `id` = '$delivery_id'";
$res_delivery = $sql->query($q_delivery);
$row_delivery = $res_delivery->fetch_array();
## Telephonie
//sku phone mensu: TELEPMENS
//sku activation: ACTTELEP
//sku transfert: TELEPTRANS
$res_tel_prod = $sql->query("SELECT `price` FROM `product` WHERE `sku` IN ('ACTTELEP','TELEPMENS','TELEPTRANS')" );
$row_tel_prod = $res_tel_prod->fetch_array();
$price_activ = $row_tel_prod['price'];
$row_tel_prod = $res_tel_prod->fetch_array();
$price_tel = $row_tel_prod['price'];
$row_tel_prod = $res_tel_prod->fetch_array();
$price_transf = $row_tel_prod['price'];
#echo " $price_tel -- $price_activ -- $price_transf ";
//placeholder prix telephonie en fibre.
$price_tel_fibre = '24.95';
$price_activ_fibre = '0';
$price_transf_fibre = '0';
$q_install = "SELECT `id`, `price` FROM `$mydbName`.`product` WHERE `id` IN (42,43,351,362,584) ORDER BY `id`";
$res_install = $sql->query($q_install);
$row_install = $res_install->fetch_array();
$option_install = "";
$row_install = $res_install->fetch_array();
$option_install .= "";
$install_value = $row_install['price'];
$row_install = $res_install->fetch_array();
$option_install .= "";
$row_install = $res_install->fetch_array();
$option_install .= "";
$row_install = $res_install->fetch_array();
$option_install .= "";
#product
$prod_blacklist = array(556,557,558, 549,551,553); //ne jamais permettre de choisir ces produits
$res_product = $sql->query("SELECT * FROM `$mydbName`.`product` WHERE `active` = '1' AND `category` IN (4,23,32) ORDER BY `sku`");
$option_product = "";
while($row_product = $res_product->fetch_array()){
if(in_array($row_product['id'],$prod_blacklist)) continue;
$option_product .= "";
}
$res_product = $sql->query("SELECT * FROM `$mydbName`.`product` WHERE `active` = '1' AND `category` IN (4,23,32) AND `type` != 2 AND `commercial` = 0 ORDER BY `sku`");
$opt_prod_sfres = "";
while($row_product = $res_product->fetch_array()){
if(in_array($row_product['id'],$prod_blacklist)) continue;
$opt_prod_sfres .= "";
}
$res_product = $sql->query("SELECT * FROM `$mydbName`.`product` WHERE `active` = '1' AND `category` IN (4,23,32) AND ((`type` = 1 AND `commercial` = 1) OR `type` NOT IN (1,2)) ORDER BY `sku`");
$opt_prod_sfcom = "";
while($row_product = $res_product->fetch_array()){
if(in_array($row_product['id'],$prod_blacklist)) continue;
$opt_prod_sfcom .= "";
}
$res_product = $sql->query("SELECT * FROM `$mydbName`.`product` WHERE `active` = '1' AND `category` IN (4,23,26,32) AND `type`!= 1 AND `commercial` = 0 ORDER BY `sku`");
$opt_prod_fibres = "";
while($row_product = $res_product->fetch_array()){
if(in_array($row_product['id'],$prod_blacklist)) continue;
$opt_prod_fibres .= "";
}
$res_product = $sql->query("SELECT * FROM `$mydbName`.`product` WHERE `active` = '1' AND `category` IN (4,23,26,32) AND ((`type` = 2 AND `commercial` = 1) OR `type` NOT IN (1,2)) ORDER BY `sku`");
$opt_prod_fibcom = "";
while($row_product = $res_product->fetch_array()){
if(in_array($row_product['id'],$prod_blacklist)) continue;
$opt_prod_fibcom .= "";
}
## Tele
$res_tele = $sql->query("SELECT * FROM `$mydbName`.`product` WHERE `active` = '1' AND `category` = 33 AND `type` = 4 ORDER BY `sku`");
$option_tele = "";
while($row_tele = $res_tele->fetch_array()){
if($row_tele['id'] == 561) continue; //package de base, a eviter
$option_tele .= "";
}
$option_tele .= "";
## fibre id - tente de trouver le id dans la table fibre.
$civic = explode(' ',$row_delivery['address1'],2);
$rue = trim($civic[1]);
$civic = trim(str_replace(',','',$civic[0]));
$zip = str_replace(' ','',$row_delivery['zip']);
$q_fibre = "SELECT * FROM `fibre` WHERE `zip` = '$zip' AND `terrain` = '$civic'";
$res_fibre = $sql->query($q_fibre);
$fibre_find = 0;
$fibre_result = '';
if($res_fibre->num_rows > 0){
$fibre_result .= "Addresse disponible (UN option DOIT être selectionné): Si vous croyez que l'adresse devrait être disponible, valider avec Dominique ou Pierre pour vous assurer que l'adresse a bien été ajoutée via la map infrastructure.