Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 88
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 215
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 216
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 217
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 218
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 219
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 220
middleware('auth');
}
public function post_data_staff_single(Request $request){
$batch = time()."-".rand()."-".uniqid();
// creating array for post data
foreach(DB::table('users')->where('id',$request->staff_id)->where('branch_id',Session::get('user')['branch_id'])->get() as $user){
$data =array(
'branch_id'=>Session::get('user')['branch_id'],
'sent_id'=>$request->staff_id,
'type'=>'staff',
'mobile'=>"255".substr(preg_replace('/\D/', '', $user->mobile),-9),
'sms'=>$request->sms,
'batch'=>$batch,
);
DB::table('sms_sent')->insert($data);
}
return redirect('/sms/preview?batch='.base64_encode($batch));
}
public function post_data_staff_all(Request $request){
$batch = time()."-".rand()."-".uniqid();
// creating array for post data
foreach(DB::table('users')->where('branch_id',Session::get('user')['branch_id'])->get() as $user){
$data =array(
'branch_id'=>Session::get('user')['branch_id'],
'sent_id'=>$user->id,
'type'=>'staff',
'mobile'=>"255".substr(preg_replace('/\D/', '', $user->mobile),-9),
'sms'=>$request->sms,
'batch'=>$batch,
);
DB::table('sms_sent')->insert($data);
}
return redirect('/sms/preview?batch='.base64_encode($batch));
}
public function post_data_customer_single(Request $request){
$batch = time()."-".rand()."-".uniqid();
// creating array for post data
foreach(DB::table('borrowers')->where('id',$request->customer_id)->where('branch_id',Session::get('user')['branch_id'])->get() as $user){
$data =array(
'branch_id'=>Session::get('user')['branch_id'],
'sent_id'=>$request->customer_id,
'type'=>'customer',
'mobile'=>"255".substr(preg_replace('/\D/', '', $user->phone),-9),
'sms'=>$request->sms,
'batch'=>$batch,
);
DB::table('sms_sent')->insert($data);
}
return redirect('/sms/preview?batch='.base64_encode($batch));
}
public function post_data_customer_all(Request $request){
$batch = time()."-".rand()."-".uniqid();
// creating array for post data
foreach(DB::table('borrowers')->where('branch_id',Session::get('user')['branch_id'])->get() as $user){
$data =array(
'branch_id'=>Session::get('user')['branch_id'],
'sent_id'=>$user->id,
'type'=>'customer',
'mobile'=>"255".substr(preg_replace('/\D/', '', $user->phone),-9),
'sms'=>$request->sms,
'batch'=>$batch,
);
DB::table('sms_sent')->insert($data);
}
return redirect('/sms/preview?batch='.base64_encode($batch));
}
public function process(){
$batch = base64_decode($_REQUEST['batch']);
if(isset($_REQUEST['cancel'])){
DB::table('sms_sent')->where('batch',$batch)->where('branch_id',Session::get('user')['branch_id'])->delete();
return redirect('/sms/send');
}else{
$header="AFELSMS";
$sms_price = 50;
foreach(DB::table('sms_header')->where('branch_id',Session::get('user')['branch_id'])->get() as $smsheader){
$header = $smsheader->name;
$sms_price = $smsheader->sms_price;
}
$sms = DB::table('sms_sent')->where('batch',$batch)->where('branch_id',Session::get('user')['branch_id'])->get();
$sms_count = $balance = 0;
$messages_array = array();
foreach($sms as $message){
$sms_count = $sms_count + ceil(strlen($message->sms)/158);
$messages_array[] = array(
'text' => $message->sms,
'msisdn' => $message->mobile,
'source' => $header,
);
}
foreach(DB::table('sms_balance')->where('branch_id',Session::get('user')['branch_id'])->get() as $balance){
$balance = $balance->amount;
}
$total_cost = $sms_price*$sms_count;
if($balance >= $total_cost){
$postData = array(
'channel' => array(
'channel' => 118994,
'password' => "Y2M2YWUwNjc2ZWVmM2UzNWU5MzcwN2M1YTFlYTUxM2M0MTA2MjA4NzJiNWMyNDM5MzBiNGQ5MmFhNTJlOWNiMw=="
),
'messages' => $messages_array
);
$ch = curl_init('https://secure-gw.fasthub.co.tz/fasthub/messaging/json/api');
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($postData)
));
$responseData = curl_exec($ch);
if (curl_error($ch)) {
return redirect('/sms/preview?error&batch='.base64_encode($batch));
}else{
// updating the balance
$new_balance = $balance - $total_cost;
DB::table('sms_balance')->where('branch_id',Session::get('user')['branch_id'])->update(array('balance'=>$new_balance));
// Updating the status
DB::table('sms_sent')->where('batch',$batch)->where('branch_id',Session::get('user')['branch_id'])->update(array('status'=>1));
// insert records for sms expenses;
$expense = array(
'branch_id'=>Session::get('user')['branch_id'],
'batch'=>$batch,
'cost'=>$total_cost,
);
DB::table('sms_expenses')->insert($expense);
return redirect('/sms/preview?sent=true&batch='.base64_encode($batch));
}
}else{
return redirect('/sms/preview?not&batch='.base64_encode($batch));
}
}
}
}