Beispiel #1
0
function dateRange($page = 1, $from_interval = 7)
{
    $to_days = ($page - 1) * $from_interval;
    $from_days = $page * $from_interval - 1;
    # create a range to fill in rows with no trips
    $date_to = date('Y-m-d', strtotime('-' . $to_days . ' days'));
    $date_from = date('Y-m-d', strtotime('-' . $from_days . ' days'));
    $dates = createDateRangeArray($date_from, $date_to);
    rsort($dates);
    return $dates;
}
Beispiel #2
0
/**
 * Nächste Woche funktioniert noch nicht, weil Datum nicht ermittelt wird...
 * @param  [type] $obj    [description]
 * @return [type]         [description]
 */
function tablesToArr($obj)
{
    $arr = array();
    $timeframe = explode(" - ", trim($obj->find('> text', 2), " \t\n\r\v()"));
    $dates[0] = createDateRangeArray($timeframe[0], $timeframe[1]);
    //$dates[1] = createDateRangeArray("14.12.15", "18.12.15");
    $tables = $obj->find('table');
    if (array_key_exists(0, $tables) && array_key_exists(1, $tables) && array_key_exists(0, $dates) && array_key_exists(1, $dates)) {
        return array_merge(tableToArr($tables[0], $dates[0]), tableToArr($tables[1], $dates[1]));
    } elseif (array_key_exists(0, $tables) && array_key_exists(0, $dates)) {
        return tableToArr($tables[0], $dates[0]);
    } else {
        return false;
    }
}
Beispiel #3
0
 public function get_sms_data()
 {
     $where = "";
     if (!DashboardCommon::is_su()) {
         $where = " AND gsm_number IN( " . $this->get_gsm_number() . " ) {$this->sms_data_limit_clause}\n                ORDER BY sms_dt DESC";
     }
     $dates = createDateRangeArray($this->from, $this->to);
     $data_array = array();
     foreach ($dates as $date) {
         $sql = "SELECT count(*) as total FROM sms ";
         $sql .= "WHERE sms_dt LIKE '%" . $date . "%' {$where}";
         // echo $sql;
         $res = DashboardCommon::db()->Execute($sql);
         $data_array[] = array('elapsed' => userdate($date), 'value' => $res->fields['total']);
     }
     return $data_array;
 }
Beispiel #4
0
function CollectData($type_for_search, $username, $strDateFrom, $strDateTo)
{
    //$strDateFrom = date('Y-m-d', strtotime($year."W".$week_number.'-1'));
    //$strDateTo = date('Y-m-d', strtotime($year."W".$week_number.'-7'));
    //echo $strDateFrom;
    //echo $strDateTo;
    // $strDateFrom = date("Y-m-d",strtotime('monday this week'));
    // $strDateTo = date("Y-m-d",strtotime("sunday this week"));
    // echo 'from';
    // echo $strDateFrom;
    // echo 'to';
    // echo $strDateTo;
    $dates_array = createDateRangeArray($strDateFrom, $strDateTo);
    $daily_rank_sum_arr = array();
    foreach ($dates_array as &$value) {
        //echo $value;
        if (Get_Logged_users_id()) {
            if ($type_for_search != -1) {
                $SQL = "SELECT DISTINCT SUM(homeworks.Rank) FROM homeworks,user,uh,solvedhomeworks WHERE homeworks.Type = " . $type_for_search . " AND user.Name = '" . $username . "' AND uh.HWID = homeworks.UID AND uh.USERID = user.UID AND homeworks.Date = '" . $value . "' AND homeworks.UID NOT IN (SELECT solvedhomeworks.HWID FROM solvedhomeworks WHERE solvedhomeworks.USERID = " . Get_Logged_users_id() . ")";
            } else {
                $SQL = "SELECT DISTINCT SUM(homeworks.Rank) FROM homeworks,user,uh,solvedhomeworks WHERE user.Name = '" . $username . "' AND uh.HWID = homeworks.UID AND uh.USERID = user.UID AND homeworks.Date = '" . $value . "' AND homeworks.UID IN (SELECT solvedhomeworks.HWID FROM solvedhomeworks WHERE solvedhomeworks.USERID = " . Get_Logged_users_id() . ")";
            }
        } else {
            $SQL = "SELECT DISTINCT SUM(homeworks.Rank) FROM homeworks,user,uh WHERE homeworks.Type = " . $type_for_search . " AND user.Name = '" . $username . "' AND uh.HWID = homeworks.UID AND uh.USERID = user.UID AND homeworks.Date = '" . $value . "'";
        }
        //echo $SQL;
        $result = mysql_query($SQL);
        $daily_rank_sum = mysql_fetch_array($result);
        if ($daily_rank_sum[0] <= 0) {
            $daily_rank_sum[0] = 0;
        }
        array_push($daily_rank_sum_arr, $daily_rank_sum[0]);
    }
    unset($value);
    foreach ($daily_rank_sum_arr as &$value) {
        //echo $value;
    }
    unset($value);
    $done_array = array();
    for ($i = 0; $i < sizeof($dates_array); $i++) {
        array_push($done_array, array($dates_array[$i], $daily_rank_sum_arr[$i] * 10));
    }
    return $done_array;
    // NOW LET'S USE $dates_array and $daily_rank_sum_arr for the graph :D
}
Beispiel #5
0
 public function get_emails_data()
 {
     $where = "";
     if (!DashboardCommon::is_su()) {
         //$where = " AND emails.client_id='".$this->get_unbounce_id()."'  AND test_data=0
         //ORDER BY email_date DESC";
         $where = " AND emails.client_id IN ('" . implode('\',\'', $this->get_unbounce_ids()) . "')\n                AND test_data=0 ORDER BY email_date DESC";
     }
     $dates = createDateRangeArray($this->from, $this->to);
     $data_array = array();
     foreach ($dates as $date) {
         $sql = "SELECT count(*) as total FROM emails ";
         $sql .= "WHERE CONVERT_TZ(email_date,'+00:00','+04:00') LIKE '%" . $date . "%' {$where}";
         // echo $sql;
         $res = DashboardCommon::db()->Execute($sql);
         $data_array[] = array('elapsed' => userdate($date), 'value' => $res->fields['total']);
     }
     return $data_array;
 }
Beispiel #6
0
 public function get_calls_data()
 {
     $where = "";
     if (!DashboardCommon::is_su()) {
         $where = " AND gsm_number IN( " . $this->get_gsm_number() . " )  AND test_data=0 {$this->calls_data_limit_clause}";
     }
     $arr_calls = createDateRangeArray($this->from, $this->to);
     $json_array = array();
     foreach ($arr_calls as $arr_call) {
         $sql = "SELECT count(*) as total FROM calls ";
         $sql .= "WHERE call_start LIKE '%" . $arr_call . "%' {$where}";
         $res = DashboardCommon::db()->Execute($sql);
         $json_array[] = array('elapsed' => userdate($arr_call), 'value' => $res->fields['total']);
     }
     return $json_array;
     header('Content-Type: application/json');
     echo json_encode($json_array);
     die;
 }
Beispiel #7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $date = new \DateTime();
     $date->modify('+3 days');
     $formatted_date_from = $date->format('Y-m-d');
     $date->modify('+6 days');
     $formatted_date_to = $date->format('Y-m-d');
     $dates = createDateRangeArray(strtotime($formatted_date_from), strtotime($formatted_date_to));
     $bases = Base::where('center', 1)->get();
     $current_gen = Gen::getCurrentGen();
     $shiftSessions = ShiftSession::where('active', 1)->get();
     $lastShift = Shift::where('gen_id', $current_gen->id)->orderBy('week', 'desc')->first();
     $week = $lastShift ? $lastShift->week : 0;
     foreach ($dates as $date) {
         foreach ($bases as $base) {
             foreach ($shiftSessions as $shiftSession) {
                 $shift = new Shift();
                 $shift->gen_id = $current_gen->id;
                 $shift->base_id = $base->id;
                 $shift->shift_session_id = $shiftSession->id;
                 $shift->week = $week + 1;
                 $shift->date = $date;
                 $shift->save();
             }
         }
     }
     $role_ids = Tab::find(35)->roles->pluck('id')->unique()->toArray();
     $roles = Role::whereIn('id', $role_ids)->get();
     if ($week == 0) {
         $week = 1;
     }
     foreach ($roles as $role) {
         $users = $role->users;
         foreach ($users as $user) {
             send_mail_regis_shift($user, $week, $current_gen, ['*****@*****.**']);
         }
     }
     $this->info('done');
 }
Beispiel #8
0
 public function getLeadsChartDataClient($period)
 {
     require_once dirname(__FILE__) . '/Client.php';
     $campaigns = Client::get_campaigns();
     $first_campaign_start = Client::getFirstCampaignStartDate();
     //if(empty($campaigns))            return array();
     $union_array = array();
     foreach ($campaigns as $campaign) {
         $sql = "(SELECT * FROM calls WHERE gsm_number='" . $campaign['gsm_number'] . "'";
         if ($campaign['start_date'] != '0000-00-00') {
             //if($date < $campaign['start_date']) continue;
             $sql .= " AND call_start>='" . $campaign['start_date'] . "'";
         }
         if ($campaign['end_date'] != '0000-00-00') {
             //if($date > $campaign['end_date']) continue;
             $sql .= " AND call_end<='" . $campaign['end_date'] . "'";
         }
         $sql .= ")";
         $union_array[] = $sql;
     }
     $inner_sql = implode(" UNION ", $union_array);
     if ($inner_sql == '') {
         $inner_sql = "(SELECT * FROM calls WHERE id = NULL)";
     }
     $client_calls_where = "  AND test_data=0 ORDER BY call_start DESC";
     $client_email_where = " AND client_id  IN ('" . implode('\',\'', $this->get_unbounce_ids()) . "')  AND test_data=0\n                                ORDER BY email_date DESC";
     $data = array();
     $period_days = array();
     $date_filter = "Y-m-d";
     if ($period == 'lifetime') {
         $period_days = getMonths($this->from, $this->to);
         $date_filter = "Y-m";
     } elseif ($period == 'last_30_days' || $period == 'last_7_days' || $period == 'yesterday' || $period == 'month' || $period == 'daily' || $period == 'today' || $period == 'this_month' || $period == 'custom' || $period == 'last_month') {
         $period_days = createDateRangeArray($this->from, $this->to);
     } else {
         $period_days = createDateRangeArray($this->from, $this->to);
     }
     $campaign_start_limit = "";
     if ($first_campaign_start != '') {
         $campaign_start_limit = "WHERE call_start>='{$first_campaign_start}'";
     }
     if (!empty($period_days)) {
         foreach ($period_days as $date) {
             if ($date_filter === 'Y-m-d') {
                 $date_filtered = $date;
             } else {
                 $date_filtered = date_format($date, "{$date_filter}");
             }
             $q1 = "SELECT count(*) as  total_calls FROM ({$inner_sql}) AS calls WHERE call_start LIKE '%" . $date_filtered . "%' {$client_calls_where} ";
             $c_total = 0;
             $c_total = DashboardCommon::executeAndReturnSingleColResultAndCache($q1, 'total_calls');
             $q2 = "SELECT count(*) as total_emails FROM emails WHERE \n                    CONVERT_TZ(email_date,'+00:00','+04:00') LIKE '" . $date_filtered . "%' {$client_email_where}";
             $e_total = DashboardCommon::executeAndReturnSingleColResultAndCache($q2, 'total_emails');
             $sql_leads = "SELECT * , tcalls+temails as total_leads\n                    FROM\n                    (SELECT \n                        /*COUNT(DISTINCT  /*DATE_FORMAT(call_start,'%y-%m-%d') ,// gsm_number) as tcalls*/\n                        COUNT(*) AS tcalls\n                        FROM ({$inner_sql}) AS calls \n                        WHERE\n                        id IN (  SELECT id FROM calls {$campaign_start_limit} GROUP BY callerid HAVING MIN(call_start)  ) AND\n                        call_start LIKE '%" . $date_filtered . "%' {$client_calls_where}\n                    ) as a , \n                    (SELECT \n                        COUNT(*) as temails\n                        FROM emails \n                        WHERE\n                        CONVERT_TZ(email_date,'+00:00','+04:00') LIKE '" . $date_filtered . "%' {$client_email_where}\n                    ) as b";
             //echo $sql_leads; die();
             $tot_leads = DashboardCommon::executeAndReturnSingleColResultAndCache($q1, 'total_leads');
             $row = array('y' => $date_filtered, 'a' => $c_total, 'b' => $e_total, 'c' => $tot_leads);
             $data[] = $row;
         }
     }
     return $data;
 }
Beispiel #9
0
            
            $(document).ready(function()
            {
            
                // Morris.js Graphs
                if(typeof Morris != 'undefined')
                {
                    
                    // Area Chart
                    Morris.Area({
                        element: 'chart_life_time',
                        data: [
                            <?php 
        $roi_date_from = $res_roi_graph->fields['roi_date'];
        $roi_date_to = date('Y-m-d');
        $arr_rois = createDateRangeArray($roi_date_from, $roi_date_to);
        $i = 0;
        foreach ($arr_rois as $arr_roi) {
            $i++;
            $qry_roi_month = "SELECT SUM(avg_sale_revenue) as total_lifetime FROM roi WHERE roi_date LIKE '%" . $arr_roi . "%'";
            $res_roi_month = $db->Execute($qry_roi_month);
            $roi_total = $res_roi_month->fields['total_lifetime'];
            if ($roi_total == '') {
                $roi_total = 0;
            }
            ?>
                            { y: '<?php 
            echo $arr_roi;
            ?>
', a: <?php 
            echo $roi_total;
function getbkSortedDates($booking_days)
{
    if (strpos($booking_days, ' - ') !== FALSE) {
        $booking_days = explode(' - ', $booking_days);
        $booking_days = createDateRangeArray($booking_days[0], $booking_days[1]);
    }
    $days_array = explode(',', $booking_days);
    $only_days = array();
    foreach ($days_array as $new_day) {
        if (!empty($new_day)) {
            $new_day = trim($new_day);
            if (strpos($new_day, '.') !== false) {
                $new_day = explode('.', $new_day);
            } else {
                $new_day = explode('-', $new_day);
            }
            $only_days[] = $new_day[2] . '-' . $new_day[1] . '-' . $new_day[0] . ' 00:00:00';
        }
    }
    if (!empty($only_days)) {
        sort($only_days);
    }
    return $only_days;
}
Beispiel #11
0
    if ($i < count($arr_calls)) {
        echo ",";
    }
    ?>
				
	<?php 
}
?>
			];
			
			
var today_data = [
	<?php 
$calls_date_from = date('Y-m-d');
$calls_date_to = date('Y-m-d');
$arr_calls = createDateRangeArray($calls_date_from, $calls_date_to);
$i = 0;
foreach ($arr_calls as $arr_call) {
    $i++;
    $qry_calls_month = "SELECT count(*) as month_calls_total FROM calls WHERE call_start LIKE '%" . $arr_call . "%' AND gsm_number IN( " . $client_id . " ) AND test_data=0 {$calls_data_limit_clause}";
    $res_calls_month = $db->Execute($qry_calls_month);
    ?>
	
				{"elapsed": "<?php 
    echo userdate($arr_call);
    ?>
", "value": <?php 
    echo $res_calls_month->fields['month_calls_total'];
    ?>
} <?php 
    if ($i < count($arr_calls)) {
Beispiel #12
0
 $weeks = '';
 //-- Start the Date loop
 $var = 0;
 foreach ($arrEventDates as $e) {
     $oDetails = $arrEventsDetail[$e['eventId'] . '-' . $e['eventRepId']];
     //Get original event (parent) details
     $oDetails['startdate'] = $e['date'];
     $oDetails['enddate'] = $e['end'];
     if (($oDetails['startdate'] >= $elStartDate || $oDetails['enddate'] >= $elStartDate) && $oDetails['enddate'] <= $elEndDate || $displayType == 'detail' || $elDirectional) {
         $oDetails['startdate_fstamp'] = $oDetails['startdate'];
         $oDetails['enddate_fstamp'] = $oDetails['enddate'];
         $oDetails['detailURL'] = $modx->makeUrl(!empty($ajaxResourceId) && (bool) $modalView === true ? $ajaxResourceId : $did, '', array('detail' => $e['eventId'], 'r' => $e['eventRepId']));
         if (strftime('%Y-%m-%d', $e['date']) == strftime('%Y-%m-%d', $e['end'])) {
             $events[strftime('%Y-%m-%d', $e['date'])][] = $oDetails;
         } else {
             $spandates = createDateRangeArray(strftime('%Y-%m-%d', $e['date']), strftime('%Y-%m-%d', $e['end']));
             foreach ($spandates as $spD) {
                 $events[$spD][] = $oDetails;
             }
         }
         // $output.= $e['date']. '<br/>';
     }
 }
 do {
     // Week Start date
     $iWeek = strtotime('+ ' . $var . ' week', $startMonthCalDate);
     $diw = 0;
     $days = '';
     do {
         // Get the week's days
         $iDay = strtotime('+ ' . $diw . ' day', $iWeek);
function createDateRangeArray($start, $end)
{
    $range = array();
    if (is_string($start) === true) {
        $start = strtotime($start);
    }
    if (is_string($end) === true) {
        $end = strtotime($end);
    }
    if ($start > $end) {
        return createDateRangeArray($end, $start);
    }
    do {
        $range[] = date('Y-m-d', $start);
        $start = strtotime("+ 1 day", $start);
    } while ($start <= $end);
    return $range;
}
Beispiel #14
0
    $table_name = "meals_" . $type;
    $result_db = mysql_query("SELECT * FROM {$table_name} ORDER BY idx ASC");
    $total = 0;
    foreach ($c1 as $val) {
        $row = mysql_fetch_array($result_db);
        $total = $total + $val * $row['price'];
    }
    return $total;
}
$t1 = get_total_cpw($c1, 'b');
$t2 = get_total_cpw($c2, 'l');
$t3 = get_total_cpw($c3, 's');
$t4 = get_total_cpw($c4, 'd');
$grtotal = $t1 + $t2 + $t3 + $t4;
mysql_query("UPDATE choices SET `cost_per_week_nobasic` = {$grtotal} WHERE s_id = '" . $student_id . "';");
$montharr = createDateRangeArray(date("Y-m-d", mktime(0, 0, 0, $month, 1, $year)), date("Y-m-d", mktime(0, 0, 0, $month + 1, 1, $year)));
$grtotal = 0;
foreach ($montharr as $val) {
    $grtotal = $grtotal + get_total_cpd($c1, 'b', $val);
}
foreach ($montharr as $val) {
    $grtotal = $grtotal + get_total_cpd($c2, 'l', $val);
}
foreach ($montharr as $val) {
    $grtotal = $grtotal + get_total_cpd($c3, 's', $val);
}
foreach ($montharr as $val) {
    $grtotal = $grtotal + get_total_cpd($c4, 'd', $val);
}
mysql_query("UPDATE choices SET `cost_month_nobasic` = {$grtotal} WHERE s_id = '" . $student_id . "';");
echo $grtotal;
 private function getCommaSeparatedDates($event_dates_start, $event_dates_end)
 {
     if (isset($event_dates_start['date']) && isset($event_dates_end['date'])) {
         //$start_date = date_i18n('Y-m-d',   $this->iso_to_ts( $event_dates_start['date'] )  );
         //$end_date   = date_i18n('Y-m-d', ( $this->iso_to_ts( $event_dates_end['date'] ) - 86400 ) );
         $start_date = $this->iso_to_ts($event_dates_start['date']);
         $end_date = $this->iso_to_ts($event_dates_end['date']) - 86400;
         $range_time = '00:00 - 00:00';
     }
     if (isset($event_dates_start['dateTime']) && isset($event_dates_end['dateTime'])) {
         $start_date = $this->iso_to_ts($event_dates_start['dateTime']);
         $end_date = $this->iso_to_ts($event_dates_end['dateTime']);
         $range_time = date_i18n('H:i', $start_date) . ' - ' . date_i18n('H:i', $end_date);
         //$start_date = date_i18n('Y-m-d', $start_date );
         //$end_date   = date_i18n('Y-m-d', $end_date );
     }
     $dates_comma = createDateRangeArray(date_i18n("d.m.Y", $start_date), date_i18n("d.m.Y", $end_date));
     //$dates = wpdevbkGetDaysBetween($start_date, $end_date );
     //$dates_comma = implode(', ', $dates);
     //        // Get Times
     //        $start_time  = $this->iso_to_ts( $event_dates[0]['startTime'] );
     //
     //        if ( date_i18n('H:i', $this->iso_to_ts( $event_dates[ (count($event_dates)-1) ]['endTime'] ) ) == '00:00' )
     //            $end_time = $this->iso_to_ts( $event_dates[ (count($event_dates)-1) ]['endTime'] ) - 86400; // 24 hours - 60*60*24 = 86400
     //        else
     //            $end_time = $this->iso_to_ts( $event_dates[ (count($event_dates)-1) ]['endTime'] );
     //
     //
     //        $range_time  = date_i18n('H:i', $start_time ) . ' - ' . date_i18n('H:i', $end_time );
     if ($range_time != '00:00 - 00:00') {
         $bktype = $this->getResource();
         $range_time = "select-one^rangetime{$bktype}^{$range_time}~";
     } else {
         $range_time = '';
     }
     return array($dates_comma, $range_time);
 }
Beispiel #16
0
 if (Input::has('d')) {
     $planDate = strtotime(Input::get('d'));
 }
 $monthStartDate = date('Y-m-01', $planDate);
 if (date('w', strtotime($monthStartDate)) != 0) {
     $startDate = date('Y-m-d', strtotime('last sunday, 12am', strtotime($monthStartDate)));
 } else {
     $startDate = $monthStartDate;
 }
 $monthEndDate = date('Y-m-t', $planDate);
 if (date('w', strtotime($monthEndDate)) != 6) {
     $endDate = date('Y-m-d', strtotime('next saturday, 12am', strtotime($monthEndDate)));
 } else {
     $endDate = $monthEndDate;
 }
 $dates = createDateRangeArray($startDate, $endDate);
 $meals = DB::table('meal_calendar')->leftJoin('Recipe', 'meal_calendar.recipe_id', '=', 'Recipe.RecipeId')->whereBetween('meal_date', array($startDate, $endDate))->get();
 $plans = array();
 foreach ($dates as $date) {
     $plans[$date] = array();
     foreach ($meals as $meal) {
         if (strtotime($meal->meal_date) == strtotime($date)) {
             if (isNullOrEmptyString($meal->note)) {
                 $plans[$date][$meal->id] = "Recipe-" . $meal->RecipeName;
             } else {
                 $plans[$date][$meal->id] = "Note-" . $meal->note;
             }
         }
     }
 }
 $recipes = Recipe::orderBy('RecipeName')->lists('RecipeName', 'RecipeId');
        if ($a == 1) {
            $status = $_POST["str4"];
        }
    }
    if ($b == "1") {
        $status = $_POST["str4"];
    }
}
die;
$q = mysql_query("select * from mpc_leave_application  where emp_id ='{$id}' and start_date  BETWEEN  '{$txt_date2}' AND '{$txt_date1}'");
$aa = mysql_num_rows($q);
$a = mysql_fetch_array($q);
$approved = $a['approved'];
$date1 = $a['start_date'];
$date2 = $a['end_date'];
$datePeriodl = createDateRangeArray($date1, $date2);
if ($aa > 0 && $approved == '1') {
    foreach ($datePeriodl as $datePeriodl) {
        $date_leave1 = $a['start_date'];
        $date_leave2 = $a['end_date'];
        $status = $a['leave_type'];
        $sql_check_update = "update " . $mysql_table_prefix . "attendence_master set\t\n\t\t\t\tattendance_status='{$status}',\n\t\t\t\tbadli_as ='{$badli_as}',\n\t\t\t\tshift ='{$shift}'\n\t\t\t\twhere emp_id ='{$id}' and date ='{$datePeriodl}'";
        $result_check_update = mysql_query($sql_check_update) or die("Query Failed " . mysql_error());
    }
}
if (isset($_GET['start'])) {
    if ($_GET['start'] == 'All') {
        $start = 0;
    } else {
        $start = $_GET['start'];
    }
Beispiel #18
0
 public function dashboard($domain, $gen_id, $base_id = null)
 {
     //        $current_gen = Gen::getCurrentGen();
     if ($this->user->role == 0) {
         return $this->responseUnAuthorized('Bạn không có quyền truy cập dữ liệu này');
     }
     $data = [];
     if ($gen_id) {
         $current_gen = Gen::find($gen_id);
     } else {
         return response()->json([message => "gen_id is required"], 400);
     }
     $data['current_gen'] = $this->genTransformer->transform($current_gen);
     if ($base_id == null) {
         $zero_paid_num = Register::where('gen_id', $current_gen->id)->where('status', '=', 1)->where('money', '=', 0)->count();
         $total_money = Register::where('gen_id', $current_gen->id)->sum('money');
         $num = Register::where('gen_id', $current_gen->id)->count();
         $paid_number = Register::where('gen_id', $current_gen->id)->where('code', "!=", "")->count();
         $uncalled_number = Register::where('gen_id', $current_gen->id)->where('call_status', 0)->groupBy('user_id')->count();
         $total_classes = $current_gen->studyclasses->count();
         $remain_days = strtotime($current_gen->end_time) - time();
         $registers_by_date = Register::select(DB::raw('count(1) as num'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(created_at)'))->pluck('num')->toArray();
         $money_by_date = Register::select(DB::raw('sum(money) as money'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(paid_time)'))->pluck('money')->toArray();
         $registers_by_hour = Register::select(DB::raw('HOUR(created_at) as \'hour\', count(1) as num'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('HOUR(created_at)'))->get();
         $registers_hour_array = array();
         for ($i = 0; $i < 24; $i++) {
             $registers_hour_array[$i] = 0;
         }
         foreach ($registers_by_hour as $regis) {
             $registers_hour_array[$regis->hour] = $regis->num;
         }
         $data['money_by_date'] = $money_by_date;
         $data['zero_paid_num'] = $zero_paid_num;
         $data['classes'] = $this->classTransformer->transformCollection($current_gen->studyclasses);
         $data['total_money'] = is_numeric($total_money) ? $total_money : 0;
         $data['register_number'] = is_numeric($num) ? $num : 0;
         $data['paid_number'] = is_numeric($paid_number) ? $paid_number : 0;
         $data['uncalled_number'] = is_numeric($uncalled_number) ? $uncalled_number : 0;
         $data['total_classes'] = is_numeric($total_classes) ? $total_classes : 0;
         $data['remain_days'] = round((is_numeric($remain_days) ? $remain_days : 0) / (24 * 3600), 2);
         $data['date_array'] = createDateRangeArray(strtotime($current_gen->start_time), strtotime($current_gen->end_time));
         $data['registers_by_date'] = $registers_by_date;
         $data['registers_by_hour'] = $registers_hour_array;
     } else {
         $base = Base::find($base_id);
         $classes = $base->classes()->where('gen_id', $current_gen->id);
         $registers = Register::where('gen_id', $current_gen->id)->where('gen_id', $current_gen->id)->whereIn('class_id', $classes->pluck('id'));
         $zero_paid_num = Register::where('status', '=', 1)->where('money', '=', 0)->whereIn('class_id', $classes->pluck('id'))->count();
         $total_money = $registers->sum('money');
         $num = $registers->count();
         $paid_number = $registers->where('gen_id', $current_gen->id)->where('code', "!=", "")->count();
         $uncalled_number = $registers->where('call_status', 0)->groupBy('user_id')->count();
         $total_classes = $classes->count();
         $remain_days = strtotime($current_gen->end_time) - time();
         $classes_id = $classes->pluck("id");
         $registers_by_date = Register::select(DB::raw('count(1) as num'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(created_at)'))->pluck('num')->toArray();
         $registers_by_hour = Register::select(DB::raw('HOUR(created_at) as \'hour\', count(1) as num'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('HOUR(created_at)'))->get();
         $money_by_date = Register::select(DB::raw('sum(money) as money'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(paid_time)'))->pluck('money')->toArray();
         $registers_hour_array = array();
         for ($i = 0; $i < 24; $i++) {
             $registers_hour_array[$i] = 0;
         }
         foreach ($registers_by_hour as $regis) {
             $registers_hour_array[$regis->hour] = $regis->num;
         }
         $data['money_by_date'] = $money_by_date;
         $data['zero_paid_num'] = $zero_paid_num;
         $data['classes'] = $this->classTransformer->transformCollection($current_gen->studyclasses);
         $data['total_money'] = is_numeric($total_money) ? $total_money : 0;
         $data['register_number'] = is_numeric($num) ? $num : 0;
         $data['paid_number'] = is_numeric($paid_number) ? $paid_number : 0;
         $data['uncalled_number'] = is_numeric($uncalled_number) ? $uncalled_number : 0;
         $data['total_classes'] = is_numeric($total_classes) ? $total_classes : 0;
         $data['remain_days'] = round((is_numeric($remain_days) ? $remain_days : 0) / (24 * 3600), 2);
         $data['date_array'] = createDateRangeArray(strtotime($current_gen->start_time), strtotime($current_gen->end_time));
         $data['registers_by_date'] = $registers_by_date;
         $data['registers_by_hour'] = $registers_hour_array;
     }
     return response()->json($data, 200);
 }
Beispiel #19
0
 public function save()
 {
     if ($_POST) {
         //get post
         $pData = $this->input->post(NULL, TRUE);
         //input data
         $leaveTypeID = $pData["ddlLeaveType"];
         //ประเภทการลา
         $leave_because = $pData['txtBecause'];
         $leave_start_date = dbDateFormatFromThaiUn543($pData["txtStartDate"]);
         //วันที่ลา
         $leave_start_time = $pData["txtStartTime"];
         //เวลาที่ลา
         $leave_end_date = dbDateFormatFromThaiUn543($pData["txtEndDate"]);
         //วันสิ้นสุดที่ลา
         $leave_end_time = $pData["txtEndTime"];
         //เวลาสิ้นสุดของวันที่ลา
         //hidden data
         $this->user_id = $pData["hdUserID"];
         $this->emp_id = $pData["hdEmpID"];
         $leaveID = $pData["hdLID"];
         $pagetype = $pData['hd_pagetype'];
         $pass = $this->leave->checkExistsDate($this->user_id, $leave_start_date, $leave_end_date, $leaveID);
         if (!$pass) {
             echo swalc("ลาไม่ได้นะ", "วันที่คุณลามีการลาอยู่แล้ว", "error", "history.back();");
         } else {
             if ($pagetype == 'add') {
                 $data = array();
                 $data["L_LTID"] = $leaveTypeID;
                 $data["L_UserID"] = $this->user_id;
                 $data["LBecause"] = $leave_because;
                 $data["LStartDate"] = $leave_start_date;
                 $data["LStartTime"] = $leave_start_time;
                 $data["LEndDate"] = $leave_end_date;
                 $data["LEndTime"] = $leave_end_time;
                 $data["L_WFID"] = 1;
                 $data["L_StatusID"] = 1;
                 $data["LCreatedDate"] = getDateTimeNow();
                 $data["LLatestUpdate"] = getDateTimeNow();
                 $leaveID = $this->leave->insertLeave($data);
                 $uploadPath = $this->config->item('upload_employee') . $this->user_id . '/leave/';
                 $uploadPath = uploadFileControl("fuDocument", $uploadPath, $leaveID, "leave");
             } else {
                 if ($pagetype == 'edit' || $pagetype == "editdoc") {
                     //Get old data for insert into log after update new leave data.
                     $query = $this->leave->getDetailByLeaveID($leaveID);
                     $query = $query->row_array();
                     $old_leave_detail = $query;
                     //ใช้สำหรับส่งไปฟังก์ชั่นส่งเมล์หาหัวหน้า
                     $old_start_date = dateThaiFormatFromDB($query["LStartDate"]);
                     $old_start_time = $query["LStartTime"];
                     $old_end_date = dateThaiFormatFromDB($query["LEndDate"]);
                     $old_end_time = $query["LEndTime"];
                     $old_data = array();
                     $old_data["LL_LID"] = $leaveID;
                     $old_data["LL_Type"] = "edit";
                     $old_data["LLDetail"] = "แก้ไขใบลา จากขอลาวันที่ " . $old_start_date . " " . $old_start_time . " จนถึงวันที่ " . $old_end_date . " " . $old_end_time . " แก้ไขเป็นขอลาวันที่ " . $leave_start_date . " " . $leave_start_time . " จนถึงวันที่ " . $leave_end_date . " " . $leave_end_time;
                     $old_data["LLDate"] = getDateTimeNow();
                     $old_date["LLBy"] = $this->user_id;
                     $return_wfid = $old_leave_detail["LReturn_WFID"] == NULL ? 1 : $old_leave_detail["LReturn_WFID"];
                     if ($pagetype !== "editdoc") {
                         $data = array();
                         $data["L_LTID"] = $leaveTypeID;
                         $data["L_UserID"] = $this->user_id;
                         $data["LBecause"] = $leave_because;
                         $data["LStartDate"] = $leave_start_date;
                         $data["LStartTime"] = $leave_start_time;
                         $data["LEndDate"] = $leave_end_date;
                         $data["LEndTime"] = $leave_end_time;
                         $data["L_WFID"] = $return_wfid;
                         $data["L_StatusID"] = 1;
                         $data["LLatestUpdate"] = getDateTimeNow();
                         $data["LReturn_WFID"] = NULL;
                         $where = array();
                         $where["LID"] = $leaveID;
                         $this->leave->update($data, $where);
                     } else {
                         $data = array();
                         $data["L_WFID"] = $return_wfid;
                         $data["LLatestUpdate"] = getDateTimeNow();
                         $data["LReturn_WFID"] = NULL;
                         $where = array();
                         $where["LID"] = $leaveID;
                         $this->leave->update($data, $where);
                         $old_data["LL_LID"] = $leaveID;
                         $old_data["LL_Type"] = "editdoc";
                         $old_data["LLDetail"] = "อัพโหลดเอกสารเพิ่มเติม";
                         $old_data["LLDate"] = getDateTimeNow();
                         $old_date["LLBy"] = $this->user_id;
                     }
                     $uploadPath = $this->config->item('upload_employee') . $this->user_id . '/leave/';
                     $uploadPath = uploadFileControl("fuDocument", $uploadPath, $leaveID, "editleave");
                     //update log for change data
                     $this->load->model('Leavelog_model', 'leavelog');
                     $this->leavelog->insert($old_data);
                 }
             }
             /***********************************************************************************
              * คำนวณจำนวนวันลาแล้วบันทึกลง T_LeaveTimeDetail จะเก็บเกี่ยวกับจำนวนชั่วโมงในการลาของแต่ละวัน
              * โดยคำนวณจาก T_Config ที่เก็บเวลาเริ่มทำงาน + เวลาสิ้นสุดการทำงาน โดยหักลบด้วย เวลาพัก
              * จะได้ชั่วโมงทำงานที่แท้จริง จากนั้นเอามาหักลบจากที่ลา เช่นลาตอน 4 โมงเย็น เลิกงาน 6 โมงเย็น
              * ก็บันทึกลงไปใน T_LeaveTimeDetail ว่า ลา 2  ชั่วโมงของวันที่ 23/03/2558
              * จากนั้นเวลาเอาไปคิดว่าลาไปจำนวนกี่วันแล้วก็ใช้สูตร จำนวนชั่วโมงที่ลา / เวลาทำงาน
              * แล้วบันทึกลงไปใน T_LeaveQuota
              ***********************************************************************************/
             /* This sector is find total work hour of day */
             $query = $this->configuration->getWorkTime();
             $workTimeStart = $query["workTimeStart"];
             //เวลาเริ่มทำงาน
             $workTimeEnd = $query["workTimeEnd"];
             //เวลาเลิกงาน
             $query = $this->configuration->getBreakTime();
             $breakTimeStart = $query["breakTimeStart"];
             //เวลาเริ่มพัก
             $breakTimeEnd = $query["breakTimeEnd"];
             //เวลาเลิกพัก
             $workHour = timeDiff($workTimeStart, $workTimeEnd);
             $breakHour = timeDiff($breakTimeStart, $breakTimeEnd);
             $totalWorkHour = $workHour - $breakHour;
             //Normal about time is 8 hours.
             /**
              * วนลูปเพื่อเช็คแต่ละวันใช้ลาไปวันละกี่ชั่วโมง
              * 1. ใช้ function get ว่าระหว่างวันที่เริ่ม กับ วันที่สิ้นสุดลามีวันอะไรบ้างลงใน array
              * 2. หาจำนวนชั่วโมงของวันที่ลาว่าลากี่ชั่วโมง
              * 3. บันทึกลง T_LeaveTimeDetail
              */
             $dateLeave = createDateRangeArray($leave_start_date, $leave_end_date);
             $totalLeaveHour = 0;
             $numHour = 0;
             $dataTime = array();
             $dataTime["LTD_LID"] = $leaveID;
             $dataTime["LTDDate"] = "";
             $dataTime["LTDHour"] = "";
             $dataWorkDate = $this->configuration->getWorkDate();
             $workDayStart = $dataWorkDate["workDateStart"];
             $workDayEnd = $dataWorkDate["workDateEnd"];
             //ต้องคำนวณด้วยว่าเป็นวันทำงานหรือเปล่า อย่างเช่นตอนนี้มีการผิดพลาดเกิดขึ้นเมื่อลา
             //วันศุกร์ - วันจันทร์ ตย. วันศุกร์ลา 9:00 - วันจันทร์ 9:00 จะถูกนับเป็น 4 วัน
             //ต้องเอาวันที่หยุดใน config มาหักลบด้วย ถึงจะได้ตัวเลขที่แท้จริง
             for ($i = 0; $i < count($dateLeave); $i++) {
                 if (checkWeekDay($dateLeave[$i]) >= $workDayStart && checkWeekDay($dateLeave[$i]) <= $workDayEnd) {
                     //เช็คว่าวันที่ลาอยู่ระหว่างวันทำงานหรือไม่
                     if (count($dateLeave) == 1) {
                         $numHour = timeDiff($leave_start_time, $leave_end_time);
                         if ($numHour > 6) {
                             $numHour = $numHour - $breakHour;
                         }
                         $totalLeaveHour = $totalLeaveHour + $numHour;
                     } else {
                         if ($dateLeave[$i] == $leave_start_date) {
                             $numHour = timeDiff($leave_start_time, $workTimeEnd);
                             if ($numHour > 6) {
                                 $numHour = $numHour - $breakHour;
                             }
                             //ถ้าเป็นวันเริ่มต้นให้เอาเวลาของวันเริ่มมาคำนวณหาจำนวนชั่วโมงการลา
                             $totalLeaveHour = $totalLeaveHour + $numHour;
                         } else {
                             $numHour = $totalWorkHour;
                             //ถ้าเป็นวันที่อยู่ระหว่างวันเริ่มกับวันสิ้นสุดให้เอาจำนวนชั่วโมงที่ทำงานมาเลย
                             $totalLeaveHour = $totalLeaveHour + $totalWorkHour;
                         }
                         if ($dateLeave[$i] == $leave_end_date) {
                             $numHour = timeDiff($workTimeStart, $leave_end_time);
                             //ถ้าเป็นวันสิ้นสุดการลาให้เอาเวลาของวันสิ้นสุดมาคำนวณหาจำนวนชั่วโมงการลา
                             $totalLeaveHour = $totalLeaveHour + $numHour;
                         }
                     }
                     $dataTime["LTDDate"] = $dateLeave[$i];
                     $dataTime["LTDHour"] = $numHour;
                     //case edit delete old leave time detail
                     if ($pagetype == 'edit') {
                         $this->leavetimedetail->deleteByLeaveID($leaveID);
                     }
                     $this->leavetimedetail->insertTime($dataTime);
                 }
             }
             /**
              * เอาจำนวนชั่วโมงทั้งหมด มาหารจำนวนชั่วโมงที่ต้องทำงานแต่ละวัน หาว่าใช้ไปกี่วัน
              * แล้วบันทึกลงไปที่ T_LeaveQuota
              **/
             //change to calculate all leave request to get quota
             $this->leavequota->calculate_quota($this->user_id, $leaveTypeID);
             //ใช้การคำนวณร่วมกับ leavetimedetail
             //หลังจากบันทึกทุกอย่างเสร็จแล้ว ส่ง อีเมล์บอกหัวหน้างานของตัวเองว่ามีการขอลา
             //insert log
             log_leave("send leave request", $leaveID, "ส่งใบลา", $this->user_id);
             //run workflow system
             $this->load->library("WorkflowSystem");
             $process = '';
             if ($pagetype == 'add') {
                 $this->workflowsystem->set_require_data($leaveID, "leave", "request");
                 $process = $this->workflowsystem->run();
                 //$process = $this->send_mail_to_leave_headman($leaveID,1);
             } else {
                 if ($pagetype == 'edit') {
                     $this->workflowsystem->set_require_data($leaveID, "leave", "edit request");
                     $process = $this->workflowsystem->run();
                     //$process = $this->send_mail_to_leave_headman($leaveID,1,'edit',$old_leave_detail);
                 } else {
                     if ($pagetype == 'editdoc') {
                         $this->workflowsystem->set_require_data($leaveID, "leave", "edit document");
                         $process = $this->workflowsystem->run();
                         //$process = $this->send_mail_to_leave_headman($leaveID,1,'edit',$old_leave_detail);
                     }
                 }
             }
             if ($process != 'success') {
                 echo swalc('ผิดพลาด!!', 'ระบบบันทึกการลาของคุณแล้ว แต่ไม่สามารถส่งอีเมล์ถึงหัวหน้าของคุณได้<br/>' + $this->phpmailer->ErrorInfo, 'error', "window.location.href = '" . site_url("Leave") . "'");
             } else {
                 echo swalc('สำเร็จ!!', 'บันทึกการลาของคุณพร้อมส่งอีเมล์ให้หัวหน้าเรียบร้อยแล้ว', 'success', "window.location.href = '" . site_url("Leave") . "'");
             }
         }
     }
 }
Beispiel #20
0
 public function get_dashboard_data(Request $request)
 {
     $base_id = $request->base_id;
     $current_gen = Gen::getCurrentGen();
     $gen_id = $request->gen_id;
     if ($gen_id) {
         $current_gen = Gen::find($gen_id);
     }
     $this->data['current_gen'] = $current_gen;
     if ($base_id == null) {
         $zero_paid_num = Register::where('gen_id', $current_gen->id)->where('status', '=', 1)->where('money', '=', 0)->count();
         $total_money = Register::where('gen_id', $current_gen->id)->sum('money');
         $num = Register::where('gen_id', $current_gen->id)->count();
         $paid_number = Register::where('gen_id', $current_gen->id)->where('code', "!=", "")->count();
         $uncalled_number = Register::where('gen_id', $current_gen->id)->where('call_status', 0)->groupBy('user_id')->count();
         $total_classes = $current_gen->studyclasses->count();
         $remain_days = strtotime($current_gen->end_time) - time();
         $registers_by_date = Register::select(DB::raw('count(1) as num'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(created_at)'))->pluck('num')->toArray();
         $money_by_date = Register::select(DB::raw('sum(money) as money'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(paid_time)'))->pluck('money')->toArray();
         $registers_by_hour = Register::select(DB::raw('HOUR(created_at) as \'hour\', count(1) as num'))->where('gen_id', $current_gen->id)->groupBy(DB::raw('HOUR(created_at)'))->get();
         $orders_by_hour = Order::select(DB::raw('DATE(created_at) as date,count(1) as num'))->groupBy(DB::raw('DATE(created_at)'))->get();
         $e = date('Y-m-d', time());
         $s = date('Y-m-d', time() - 24 * 60 * 60 * 7 * 4);
         $month_ago = createDateRangeArray(strtotime($s), strtotime($e));
         $orders = [];
         foreach ($orders_by_hour as $i) {
             $orders[$i->date] = $i->num;
         }
         $return_orders = [];
         foreach ($month_ago as $day) {
             if (array_key_exists($day, $orders)) {
                 $return_orders[$day] = $orders[$day];
             } else {
                 $return_orders[$day] = 0;
             }
         }
         $registers_hour_array = array();
         for ($i = 0; $i < 24; $i++) {
             $registers_hour_array[$i] = 0;
         }
         foreach ($registers_by_hour as $regis) {
             $registers_hour_array[$regis->hour] = $regis->num;
         }
         $this->data['money_by_date'] = json_encode($money_by_date);
         $this->data['zero_paid_num'] = $zero_paid_num;
         $this->data['classes'] = $current_gen->studyclasses;
         $this->data['total_money'] = is_numeric($total_money) ? $total_money : 0;
         $this->data['register_number'] = is_numeric($num) ? $num : 0;
         $this->data['paid_number'] = is_numeric($paid_number) ? $paid_number : 0;
         $this->data['uncalled_number'] = is_numeric($uncalled_number) ? $uncalled_number : 0;
         $this->data['total_classes'] = is_numeric($total_classes) ? $total_classes : 0;
         $this->data['remain_days'] = round((is_numeric($remain_days) ? $remain_days : 0) / (24 * 3600), 2);
         $this->data['date_array'] = json_encode(createDateRangeArray(strtotime($current_gen->start_time), strtotime($current_gen->end_time)));
         $this->data['registers_by_date'] = json_encode($registers_by_date);
         $this->data['registers_by_hour'] = json_encode($registers_hour_array);
         $this->data['orders_by_hour'] = json_encode(array_values($return_orders));
         $this->data['month_ago'] = json_encode($month_ago);
     } else {
         $base = Base::find($base_id);
         $classes = $base->classes()->where('gen_id', $current_gen->id);
         $registers = Register::where('gen_id', $current_gen->id)->where('gen_id', $current_gen->id)->whereIn('class_id', $classes->pluck('id'));
         $zero_paid_num = Register::where('status', '=', 1)->where('money', '=', 0)->whereIn('class_id', $classes->pluck('id'))->count();
         $total_money = $registers->sum('money');
         $num = $registers->count();
         $paid_number = $registers->where('gen_id', $current_gen->id)->where('code', "!=", "")->count();
         $uncalled_number = $registers->where('call_status', 0)->groupBy('user_id')->count();
         $total_classes = $classes->count();
         $remain_days = strtotime($current_gen->end_time) - time();
         $classes_id = $classes->pluck("id");
         $registers_by_date = Register::select(DB::raw('count(1) as num'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(created_at)'))->pluck('num')->toArray();
         $registers_by_hour = Register::select(DB::raw('HOUR(created_at) as \'hour\', count(1) as num'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('HOUR(created_at)'))->get();
         $money_by_date = Register::select(DB::raw('sum(money) as money'))->whereIn("class_id", $classes_id)->where('gen_id', $current_gen->id)->groupBy(DB::raw('DATE(paid_time)'))->pluck('money')->toArray();
         $registers_hour_array = array();
         for ($i = 0; $i < 24; $i++) {
             $registers_hour_array[$i] = 0;
         }
         foreach ($registers_by_hour as $regis) {
             $registers_hour_array[$regis->hour] = $regis->num;
         }
         $this->data['money_by_date'] = json_encode($money_by_date);
         $this->data['zero_paid_num'] = $zero_paid_num;
         $this->data['classes'] = $classes->get();
         $this->data['total_money'] = is_numeric($total_money) ? $total_money : 0;
         $this->data['register_number'] = is_numeric($num) ? $num : 0;
         $this->data['paid_number'] = is_numeric($paid_number) ? $paid_number : 0;
         $this->data['uncalled_number'] = is_numeric($uncalled_number) ? $uncalled_number : 0;
         $this->data['total_classes'] = is_numeric($total_classes) ? $total_classes : 0;
         $this->data['remain_days'] = round((is_numeric($remain_days) ? $remain_days : 0) / (24 * 3600), 2);
         $this->data['date_array'] = json_encode(createDateRangeArray(strtotime($current_gen->start_time), strtotime($current_gen->end_time)));
         $this->data['registers_by_date'] = json_encode($registers_by_date);
         $this->data['registers_by_hour'] = json_encode($registers_hour_array);
     }
     return view('components.dashboard_data', $this->data);
 }
include "inc/function.php";
$id = "";
$txt_date1 = $_GET["id"];
$id = $_GET["str"];
$txt_date2 = $_GET["sdate"];
$status = $_POST["str4"];
$badli_as = $_POST["str5"];
$type = $_POST["str6"];
$shift = $_GET["str7"];
////////////////////// Markin attendence //////////////
$ip = $_SERVER['REMOTE_ADDR'];
$good_work = "";
//
$txt_date1 = str_replace("/", "-", $txt_date1);
$txt_date2 = str_replace("/", "-", $txt_date2);
$datePeriod = createDateRangeArray($txt_date1, $txt_date2);
foreach ($datePeriod as $datePeriod) {
    //
    $sql_check = "update " . $mysql_table_prefix . "attendence_master set\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tattendance_status='{$status}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbadli_as ='{$badli_as}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tshift ='{$shift}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgood_work ='{$good_work}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tInsertBy ='{$id}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tInsertDate =now(),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIpAddress ='{$ip}'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere emp_id ='{$id}' and date ='{$datePeriod}'";
    $result_check = mysql_query($sql_check) or die("Query Failed " . mysql_error());
}
?>

<?php 
if (isset($_GET['start'])) {
    if ($_GET['start'] == 'All') {
        $start = 0;
    } else {
        $start = $_GET['start'];
    }
} else {
Beispiel #22
0
}
?>
				],
				xkey: 'y',
				ykeys: ['a'],
				labels: ['ROI']
			});
			
			Morris.Area({
				element: 'chart_today_data',
				data: [
				
				<?php 
$emails_date_from = date('Y-m-d');
$emails_date_to = date('Y-m-d');
$arr_emails = createDateRangeArray($emails_date_from, $emails_date_to);
$i = 0;
foreach ($arr_emails as $arr_email) {
    $i++;
    $qry_roi_month = "SELECT SUM(avg_sale_revenue) as total_lifetime FROM roi WHERE roi_date LIKE '%" . $arr_email . "%' AND client_id='" . $client_id . "'";
    $res_roi_month = $db->Execute($qry_roi_month);
    $roi_total = $res_roi_month->fields['total_lifetime'];
    if ($roi_total == '') {
        $roi_total = 0;
    }
    ?>
					{ y: '<?php 
    echo $arr_email;
    ?>
', a: <?php 
    echo $roi_total;
Beispiel #23
0
function wpdev_bk_insert_new_booking()
{
    global $wpdb;
    make_bk_action('check_multiuser_params_for_client_side', $_POST["bktype"]);
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Define init variables
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $dates = $_POST["dates"];
    $bktype = intval($_POST["bktype"]);
    if ($bktype == 0) {
        // Error
        ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
        echo $bktype;
        ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
        bk_error('Error od saving data into DB. Unknown booking resource.', __FILE__, __LINE__);
        ?>
</div>'; </script> <?php 
        die;
    }
    $formdata = $_POST["form"];
    $formdata = escape_any_xss($formdata);
    $is_send_emeils = 1;
    if (isset($_POST["is_send_emeils"])) {
        $is_send_emeils = $_POST["is_send_emeils"];
    }
    $my_booking_id = 0;
    $my_booking_hash = '';
    if (function_exists('get_booking_title')) {
        $bk_title = get_booking_title($bktype);
    } else {
        $bk_title = '';
    }
    if (isset($_POST['my_booking_hash'])) {
        $my_booking_hash = $_POST['my_booking_hash'];
        if ($my_booking_hash != '') {
            $my_booking_id_type = false;
            $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id', false, $my_booking_hash);
            if ($my_booking_id_type !== false) {
                $my_booking_id = $my_booking_id_type[0];
                $bktype = $my_booking_id_type[1];
            }
        }
    }
    if (strpos($dates, ' - ') !== FALSE) {
        $dates = explode(' - ', $dates);
        $dates = createDateRangeArray($dates[0], $dates[1]);
    }
    //debuge($_POST);
    ///  CAPTCHA CHECKING   //////////////////////////////////////////////////////////////////////////////////////
    $the_answer_from_respondent = $_POST['captcha_user_input'];
    $prefix = $_POST['captcha_chalange'];
    if (!($the_answer_from_respondent == '' && $prefix == '')) {
        $captcha_instance = new wpdevReallySimpleCaptcha();
        $correct = $captcha_instance->check($prefix, $the_answer_from_respondent);
        if (!$correct) {
            $word = $captcha_instance->generate_random_word();
            $prefix = mt_rand();
            $captcha_instance->generate_image($prefix, $word);
            $filename = $prefix . '.png';
            $captcha_url = WPDEV_BK_PLUGIN_URL . '/js/captcha/tmp/' . $filename;
            $ref = substr($filename, 0, strrpos($filename, '.'));
            ?>
 <script type="text/javascript">
                document.getElementById('captcha_input<?php 
            echo $bktype;
            ?>
').value = '';
                // chnage img
                document.getElementById('captcha_img<?php 
            echo $bktype;
            ?>
').src = '<?php 
            echo $captcha_url;
            ?>
';
                document.getElementById('wpdev_captcha_challenge_<?php 
            echo $bktype;
            ?>
').value = '<?php 
            echo $ref;
            ?>
';
                document.getElementById('captcha_msg<?php 
            echo $bktype;
            ?>
').innerHTML =
                    '<span class="alert" style="padding: 5px 5px 4px;vertical-align: middle;text-align:center;margin:5px;"><?php 
            echo __('The code you entered is incorrect', 'wpdev-booking');
            ?>
</span>';
                document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML ='';
                jQuery('#captcha_input<?php 
            echo $bktype;
            ?>
')
                .fadeOut( 350 ).fadeIn( 300 )
                .fadeOut( 350 ).fadeIn( 400 )
                .animate( {opacity: 1}, 4000 )
                ;  // mark red border
                jQuery("span.wpdev-help-message span.alert")
                .fadeIn( 1 )
                //.css( {'color' : 'red'} )
                .animate( {opacity: 1}, 10000 )
                .fadeOut( 2000 );   // hide message
                document.getElementById('captcha_input<?php 
            echo $bktype;
            ?>
').focus();    // make focus to elemnt
                jQuery('#booking_form_div<?php 
            echo $bktype;
            ?>
 input[type=button]').prop("disabled", false);
            </script> <?php 
            die;
        }
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $my_modification_date = "'" . date_i18n('Y-m-d H:i:s') . "'";
    // Localize booking modification date
    //$my_modification_date = 'NOW()';                                  // Server value modification date
    if ($my_booking_id > 0) {
        // Edit exist booking
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') !== false) {
            ?>
 <script type="text/javascript">
                document.getElementById('ajax_working').innerHTML =
                    '<div class="updated ajax_message" id="ajax_message">\n\
                        <div style="float:left;"><?php 
            echo __('Updating...', 'wpdev-booking');
            ?>
</div> \n\
                        <div class="wpbc_spin_loader">\n\
                               <img src="'+wpdev_bk_plugin_url+'/img/ajax-loader.gif">\n\
                        </div>\n\
                    </div>';
            </script> <?php 
        }
        $update_sql = "UPDATE {$wpdb->prefix}booking AS bk SET bk.form='{$formdata}', bk.booking_type={$bktype} , bk.modification_date={$my_modification_date} WHERE bk.booking_id={$my_booking_id};";
        if (false === $wpdb->query($update_sql)) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking in DB', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        // Check if dates already aproved or no
        $slct_sql = "SELECT approved FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$my_booking_id}) LIMIT 0,1";
        $slct_sql_results = $wpdb->get_results($slct_sql);
        if (count($slct_sql_results) > 0) {
            $is_approved_dates = $slct_sql_results[0]->approved;
        }
        $delete_sql = "DELETE FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$my_booking_id})";
        if (false === $wpdb->query($delete_sql)) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking for deleting dates in DB', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        $booking_id = (int) $my_booking_id;
        //Get ID  of reservation
    } else {
        // Add new booking
        $sql_insertion = "INSERT INTO {$wpdb->prefix}booking (form, booking_type, modification_date) VALUES ('{$formdata}',  {$bktype}, {$my_modification_date} )";
        if (false === $wpdb->query($sql_insertion)) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into DB', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        // Make insertion into BOOKINGDATES
        $booking_id = (int) $wpdb->insert_id;
        //Get ID  of reservation
        $is_approved_dates = '0';
        $auto_approve_new_bookings_is_active = get_bk_option('booking_auto_approve_new_bookings_is_active');
        if (trim($auto_approve_new_bookings_is_active) == 'On') {
            $is_approved_dates = '1';
        }
    }
    $my_dates = explode(",", $dates);
    $i = 0;
    foreach ($my_dates as $md) {
        $my_dates[$i] = trim($my_dates[$i]);
        $i++;
    }
    $start_end_time = get_times_from_bk_form($formdata, $my_dates, $bktype);
    $start_time = $start_end_time[0];
    $end_time = $start_end_time[1];
    $my_dates = $start_end_time[2];
    make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time));
    $my_cost = apply_bk_filter('get_booking_cost_from_db', '', $booking_id);
    $i = 0;
    foreach ($my_dates as $md) {
        // Set in dates in such format: yyyy.mm.dd
        if ($md != '') {
            $md = explode('.', $md);
            $my_dates[$i] = $md[2] . '.' . (intval($md[1]) < 10 ? '0' . intval($md[1]) : $md[1]) . '.' . (intval($md[0]) < 10 ? '0' . intval($md[0]) : $md[0]);
        } else {
            unset($my_dates[$i]);
        }
        // If some dates is empty so remove it   // This situation can be if using several bk calendars and some calendars is not checked
        $i++;
    }
    //debuge($my_dates);
    sort($my_dates);
    // Sort dates
    //debuge($my_dates);
    $my_dates4emeil = '';
    $i = 0;
    $insert = '';
    $my_date_previos = '';
    foreach ($my_dates as $my_date) {
        $i++;
        // Loop through all dates
        if (strpos($my_date, '.') !== false) {
            if (get_bk_option('booking_recurrent_time') !== 'On') {
                $my_date = explode('.', $my_date);
                if ($i == 1) {
                    if (!isset($start_time[0]) || empty($start_time[0])) {
                        $start_time[0] = '00';
                    }
                    if (!isset($start_time[1]) || empty($start_time[1])) {
                        $start_time[1] = '00';
                    }
                    if ($start_time[0] == '00' && $start_time[1] == '00') {
                        $start_time[2] = '00';
                    }
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]);
                } elseif ($i == count($my_dates)) {
                    if (!isset($end_time[0]) || empty($end_time[0])) {
                        $end_time[0] = '00';
                    }
                    if (!isset($end_time[1]) || empty($end_time[1])) {
                        $end_time[1] = '00';
                    }
                    if ($end_time[0] == '00' && $end_time[1] == '00') {
                        $end_time[2] = '00';
                    }
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]);
                } else {
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00');
                }
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
            } else {
                if ($my_date_previos == $my_date) {
                    continue;
                }
                // escape for single day selections.
                $my_date_previos = $my_date;
                $my_date = explode('.', $my_date);
                $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]);
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
                $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]);
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
            }
        }
    }
    $my_dates4emeil = substr($my_dates4emeil, 0, -1);
    $my_dates4emeil_check_in_out = explode(',', $my_dates4emeil);
    $my_check_in_date = change_date_format($my_dates4emeil_check_in_out[0]);
    $my_check_out_date = change_date_format($my_dates4emeil_check_in_out[count($my_dates4emeil_check_in_out) - 1]);
    // Save the sort date
    $sql_sort_date = "UPDATE {$wpdb->prefix}booking SET sort_date = '" . $my_dates4emeil_check_in_out[0] . "' WHERE booking_id  = " . $booking_id . " ";
    $wpdb->query($sql_sort_date);
    if (!empty($insert)) {
        if (false === $wpdb->query("INSERT INTO {$wpdb->prefix}bookingdates (booking_id, booking_date, approved) VALUES " . $insert)) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into BD - Dates', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
    }
    if ($my_booking_id > 0) {
        // For editing exist booking
        if ($is_send_emeils != 0) {
            sendModificationEmails($booking_id, $bktype, $formdata);
        }
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) {
            do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $formdata);
        }
        ?>
 <script type="text/javascript">
        <?php 
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) {
            ?>
                    setReservedSelectedDates('<?php 
            echo $bktype;
            ?>
');
            <?php 
        } else {
            ?>
                    document.getElementById('ajax_message').innerHTML = '<?php 
            echo __('Updated successfully', 'wpdev-booking');
            ?>
';
                    jQuery('#ajax_message').fadeOut(1000);
                    document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            echo __('Updated successfully', 'wpdev-booking');
            ?>
</div>';
                    if ( jQuery('#wpdev_http_referer').length > 0 ) {
                           location.href=jQuery('#wpdev_http_referer').val();
                    } else location.href='admin.php?page=<?php 
            echo WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME;
            ?>
wpdev-booking&view_mode=vm_listing&tab=actions&wh_booking_id=<?php 
            echo $my_booking_id;
            ?>
';
            <?php 
        }
        ?>
            </script> <?php 
    } else {
        // For inserting NEW booking
        if (count($my_dates) > 0) {
            if ($is_send_emeils != 0) {
                sendNewBookingEmails($booking_id, $bktype, $formdata);
            }
        }
        do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $formdata);
        /*
                // Start Mail Chimp Customization
                $booking_form_show = get_form_content ($formdata , $bktype );
                if ( ( isset ($booking_form_show['subscribe_me'] )) && ( $booking_form_show['subscribe_me'] == 'yes') ) {
        
                    if (file_exists(WPDEV_BK_PLUGIN_DIR. '/lib/MailChimp.class.php')) { // Include MailChimp class (You can download it from  here https://github.com/drewm/mailchimp-api/ )
                        require_once(WPDEV_BK_PLUGIN_DIR. '/lib/MailChimp.class.php' ); 
        
                        $MailChimp = new MailChimp('key-my');                          // You are need to specify here YOUR KEY !!!!
        
                        $result = $MailChimp->call('lists/subscribe', array(
                                        'id'                => 'id' . $booking_id ,          
                                        'email'             => array('email'=>$booking_form_show['email']),
                                        'merge_vars'        => array('FNAME'=>$booking_form_show['name'], 'LNAME'=>$booking_form_show['secondname']),
                                        'double_optin'      => false,
                                        'update_existing'   => true,
                                        'replace_interests' => false,
                                        'send_welcome'      => false,
                                    ));
                        // print_r($result);
                    }
                } // End Mail Chimp Customization
                /**/
        $auto_approve_new_bookings_is_active = get_bk_option('booking_auto_approve_new_bookings_is_active');
        if (trim($auto_approve_new_bookings_is_active) == 'On') {
            sendApproveEmails($booking_id, 1);
        }
        ?>
 <script type="text/javascript"> setReservedSelectedDates('<?php 
        echo $bktype;
        ?>
'); </script>  <?php 
    }
    // ReUpdate booking resource TYPE if its needed here
    if (!empty($dates)) {
        // check to have dates not empty
        make_bk_action('wpdev_booking_reupdate_bk_type_to_childs', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $formdata);
    }
}
Beispiel #24
0
?>
, year -> <?php 
echo $_POST['cyear'];
?>
</h4>

		<table  id="courses" width="90%" align="middle" class="result"><tbody><tr><td >S.No</td><td>Roll No</td><td>Name</td><td>Amount</td></tr>
		</tbody><tbody>

	<?php 
include 'mysqlconnect.php';
include 'calc_month.php';
$month = $_POST['cmonth'];
$year = str_replace("20", "", $_POST['cyear']);
$custdb = "pat_mess" . '_' . $month . '_' . $year . '.choices';
$montharr = createDateRangeArray(date("Y-m-d", mktime(0, 0, 0, $_POST['smonth'], $_POST['sday'], $_POST['syear'])), date("Y-m-d", mktime(0, 0, 0, $_POST['emonth'], $_POST['eday'], $_POST['eyear'])));
$result_db = mysql_query("SELECT * FROM {$custdb} ORDER BY s_id ASC");
$cnt2 = 1;
while ($row = mysql_fetch_array($result_db)) {
    $grtotal = 0;
    $c1 = $row['choices_b'];
    $c2 = $row['choices_l'];
    $c3 = $row['choices_s'];
    $c4 = $row['choices_d'];
    foreach ($montharr as $val) {
        $grtotal = $grtotal + get_total_cpd_db($c1, 'b', $val, "pat_mess" . '_' . $month . '_' . $year);
    }
    foreach ($montharr as $val) {
        $grtotal = $grtotal + get_total_cpd_db($c2, 'l', $val, "pat_mess" . '_' . $month . '_' . $year);
    }
    foreach ($montharr as $val) {
function wpdev_bk_insert_new_booking()
{
    make_bk_action('check_multiuser_params_for_client_side', $_POST["bktype"]);
    global $wpdb;
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Define init variables
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $dates = $_POST["dates"];
    $bktype = $_POST["bktype"];
    $formdata = $_POST["form"];
    $formdata = escape_any_xss($formdata);
    $is_send_emeils = 1;
    if (isset($_POST["is_send_emeils"])) {
        $is_send_emeils = $_POST["is_send_emeils"];
    }
    $my_booking_id = 0;
    $my_booking_hash = '';
    if (isset($_POST['my_booking_hash'])) {
        $my_booking_hash = $_POST['my_booking_hash'];
        if ($my_booking_hash != '') {
            $my_booking_id_type = false;
            $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id', false, $my_booking_hash);
            if ($my_booking_id_type !== false) {
                $my_booking_id = $my_booking_id_type[0];
                $bktype = $my_booking_id_type[1];
            }
        }
    }
    if (strpos($dates, ' - ') !== FALSE) {
        $dates = explode(' - ', $dates);
        $dates = createDateRangeArray($dates[0], $dates[1]);
    }
    ///  CAPTCHA CHECKING   //////////////////////////////////////////////////////////////////////////////////////
    $the_answer_from_respondent = $_POST['captcha_user_input'];
    $prefix = $_POST['captcha_chalange'];
    if (!($the_answer_from_respondent == '' && $prefix == '')) {
        $captcha_instance = new wpdevReallySimpleCaptcha();
        $correct = $captcha_instance->check($prefix, $the_answer_from_respondent);
        if (!$correct) {
            $word = $captcha_instance->generate_random_word();
            $prefix = mt_rand();
            $captcha_instance->generate_image($prefix, $word);
            $filename = $prefix . '.png';
            $captcha_url = WPDEV_BK_PLUGIN_URL . '/js/captcha/tmp/' . $filename;
            $ref = substr($filename, 0, strrpos($filename, '.'));
            ?>
 <script type="text/javascript">
                        document.getElementById('captcha_input<?php 
            echo $bktype;
            ?>
').value = '';
                        // chnage img
                        document.getElementById('captcha_img<?php 
            echo $bktype;
            ?>
').src = '<?php 
            echo $captcha_url;
            ?>
';
                        document.getElementById('wpdev_captcha_challenge_<?php 
            echo $bktype;
            ?>
').value = '<?php 
            echo $ref;
            ?>
';
                        document.getElementById('captcha_msg<?php 
            echo $bktype;
            ?>
').innerHTML =
                            '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            echo __('Your entered code is incorrect', 'wpdev-booking');
            ?>
</div>';
                        document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML ='';
                        jQuery('#captcha_input<?php 
            echo $bktype;
            ?>
')
                        .fadeOut( 350 ).fadeIn( 300 )
                        .fadeOut( 350 ).fadeIn( 400 )
                        .animate( {opacity: 1}, 4000 )
                        ;  // mark red border
                        jQuery(".wpdev-help-message div")
                        .css( {'color' : 'red'} )
                        .animate( {opacity: 1}, 10000 )
                        .fadeOut( 2000 );   // hide message
                        document.getElementById('captcha_input<?php 
            echo $bktype;
            ?>
').focus();    // make focus to elemnt

                    </script> <?php 
            die;
        }
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    $booking_form_show = get_form_content($formdata, $bktype);
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $my_modification_date = "'" . date_i18n('Y-m-d H:i:s') . "'";
    // Localize booking modification date
    $my_modification_date = 'NOW()';
    // Server value modification date
    if ($my_booking_id > 0) {
        // Edit exist booking
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') !== false) {
            ?>
 <script type="text/javascript">
                        document.getElementById('ajax_working').innerHTML =
                            '<div class="info_message ajax_message" id="ajax_message">\n\
                                            <div style="float:left;"><?php 
            echo __('Updating...', 'wpdev-booking');
            ?>
</div> \n\
                                            <div  style="float:left;width:80px;margin-top:-3px;">\n\
                                                   <img src="'+wpdev_bk_plugin_url+'/img/ajax-loader.gif">\n\
                                            </div>\n\
                                        </div>';
                    </script> <?php 
        }
        $update_sql = "UPDATE " . $wpdb->prefix . "booking AS bk SET bk.form='{$formdata}', bk.booking_type={$bktype} , bk.modification_date=" . $my_modification_date . " WHERE bk.booking_id={$my_booking_id};";
        if (false === $wpdb->query($wpdb->prepare($update_sql))) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking in BD', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        // Check if dates already aproved or no
        $slct_sql = "SELECT approved FROM " . $wpdb->prefix . "bookingdates WHERE booking_id IN ({$my_booking_id}) LIMIT 0,1";
        $slct_sql_results = $wpdb->get_results($wpdb->prepare($slct_sql));
        if (count($slct_sql_results) > 0) {
            $is_approved_dates = $slct_sql_results[0]->approved;
        }
        $delete_sql = "DELETE FROM " . $wpdb->prefix . "bookingdates WHERE booking_id IN ({$my_booking_id})";
        if (false === $wpdb->query($wpdb->prepare($delete_sql))) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking for deleting dates in BD', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        $booking_id = (int) $my_booking_id;
        //Get ID  of reservation
    } else {
        // Add new booking
        $sql_insertion = "INSERT INTO " . $wpdb->prefix . "booking (form, booking_type, modification_date) VALUES ('{$formdata}',  {$bktype}, " . $my_modification_date . " )";
        //debuge($formdata);
        if (false === $wpdb->query($wpdb->prepare($sql_insertion))) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into BD', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        // Make insertion into BOOKINGDATES
        $booking_id = (int) $wpdb->insert_id;
        //Get ID  of reservation
        $is_approved_dates = '0';
        $auto_approve_new_bookings_is_active = get_bk_option('booking_auto_approve_new_bookings_is_active');
        if (trim($auto_approve_new_bookings_is_active) == 'On') {
            $is_approved_dates = '1';
        }
    }
    $sdform = $_POST['form'];
    $my_dates = explode(",", $dates);
    $i = 0;
    foreach ($my_dates as $md) {
        $my_dates[$i] = trim($my_dates[$i]);
        $i++;
    }
    $start_end_time = get_times_from_bk_form($sdform, $my_dates, $bktype);
    $start_time = $start_end_time[0];
    $end_time = $start_end_time[1];
    $my_dates = $start_end_time[2];
    make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time));
    $my_cost = apply_bk_filter('get_booking_cost_from_db', '', $booking_id);
    $i = 0;
    foreach ($my_dates as $md) {
        // Set in dates in such format: yyyy.mm.dd
        if ($md != '') {
            $md = explode('.', $md);
            $my_dates[$i] = $md[2] . '.' . $md[1] . '.' . $md[0];
        } else {
            unset($my_dates[$i]);
        }
        // If some dates is empty so remove it   // This situation can be if using several bk calendars and some calendars is not checked
        $i++;
    }
    sort($my_dates);
    // Sort dates
    $my_dates4emeil = '';
    $i = 0;
    $insert = '';
    $my_date_previos = '';
    foreach ($my_dates as $my_date) {
        $i++;
        // Loop through all dates
        if (strpos($my_date, '.') !== false) {
            if (get_bk_option('booking_recurrent_time') !== 'On') {
                $my_date = explode('.', $my_date);
                if ($i == 1) {
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]);
                } elseif ($i == count($my_dates)) {
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]);
                } else {
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00');
                }
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
            } else {
                if ($my_date_previos == $my_date) {
                    continue;
                }
                // escape for single day selections.
                $my_date_previos = $my_date;
                $my_date = explode('.', $my_date);
                $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]);
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
                $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]);
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
            }
        }
    }
    $my_dates4emeil = substr($my_dates4emeil, 0, -1);
    $my_dates4emeil_check_in_out = explode(',', $my_dates4emeil);
    $my_check_in_date = change_date_format($my_dates4emeil_check_in_out[0]);
    $my_check_out_date = change_date_format($my_dates4emeil_check_in_out[count($my_dates4emeil_check_in_out) - 1]);
    /* // This add 1 more day for check out day
       $my_check_out_date = $my_dates4emeil_check_in_out[ count($my_dates4emeil_check_in_out)-1 ];
       $dt = trim($my_check_out_date);
       $dta = explode(' ',$dt);
       $dta = $dta[0];
       $dta = explode('-',$dta);
       $my_check_out_date = date('Y-m-d H:i:s' , mktime(0, 0, 0, $dta[1], ($dta[2]+1), $dta[0] ));
       $my_check_out_date = change_date_format($my_check_out_date);
       /**/
    if (!empty($insert)) {
        if (false === $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "bookingdates (booking_id, booking_date, approved) VALUES " . $insert))) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into BD - Dates', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
    }
    if (function_exists('get_booking_title')) {
        $bk_title = get_booking_title($bktype);
    } else {
        $bk_title = '';
    }
    if ($my_booking_id > 0) {
        // For editing exist booking
        $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_modification_adress'));
        $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_modification_subject'));
        $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_modification_content'));
        $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject);
        $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body);
        if (function_exists('get_booking_title')) {
            $bk_title = get_booking_title($bktype);
        } else {
            $bk_title = '';
        }
        $booking_form_show = get_form_content($formdata, $bktype);
        $mail_body_to_send = str_replace('[bookingtype]', $bk_title, $mail_body);
        if (get_bk_option('booking_date_view_type') == 'short') {
            $my_dates_4_send = get_dates_short_format(get_dates_str($booking_id));
        } else {
            $my_dates_4_send = change_date_format(get_dates_str($booking_id));
        }
        $mail_body_to_send = str_replace('[dates]', $my_dates_4_send, $mail_body_to_send);
        $mail_body_to_send = str_replace('[check_in_date]', $my_check_in_date, $mail_body_to_send);
        $mail_body_to_send = str_replace('[check_out_date]', $my_check_out_date, $mail_body_to_send);
        $mail_body_to_send = str_replace('[id]', $booking_id, $mail_body_to_send);
        $mail_body_to_send = str_replace('[content]', $booking_form_show['content'], $mail_body_to_send);
        if (!isset($denyreason)) {
            $denyreason = '';
        }
        $mail_body_to_send = str_replace('[denyreason]', $denyreason, $mail_body_to_send);
        $mail_body_to_send = str_replace('[name]', $booking_form_show['name'], $mail_body_to_send);
        $mail_body_to_send = str_replace('[cost]', $my_cost, $mail_body_to_send);
        if (isset($booking_form_show['secondname'])) {
            $mail_body_to_send = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body_to_send);
        }
        $mail_body_to_send = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body_to_send);
        $mail_body_to_send = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body_to_send, $booking_id);
        $mail_subject = str_replace('[name]', $booking_form_show['name'], $mail_subject);
        if (isset($booking_form_show['secondname'])) {
            $mail_subject = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject);
        }
        $mail_recipient = $booking_form_show['email'];
        $mail_headers = "From: {$mail_sender}\n";
        $mail_headers .= "Content-Type: text/html\n";
        if (get_bk_option('booking_is_email_modification_adress') != 'Off') {
            // Send to the Visitor
            if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) {
                if ($is_send_emeils != 0) {
                    @wp_mail($mail_recipient, $mail_subject, $mail_body_to_send, $mail_headers);
                }
            }
            // Send to the Admin also
            $mail_recipient = htmlspecialchars_decode(get_bk_option('booking_email_reservation_adress'));
            $is_email_modification_send_copy_to_admin = get_bk_option('booking_is_email_modification_send_copy_to_admin');
            if ($is_email_modification_send_copy_to_admin == 'On') {
                if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) {
                    if ($is_send_emeils != 0) {
                        @wp_mail($mail_recipient, $mail_subject, $mail_body_to_send, $mail_headers);
                    }
                }
            }
        }
        //debuge($_SERVER);
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) {
            do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $sdform);
        }
        ?>
 <script type="text/javascript">
                <?php 
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) {
            ?>
                            //document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div class=\"submiting_content\" ><?php 
            echo get_bk_option('booking_title_after_reservation');
            ?>
</div>';
                            //jQuery('.submiting_content').fadeOut(<?php 
            echo get_bk_option('booking_title_after_reservation_time');
            ?>
);
                            setReservedSelectedDates('<?php 
            echo $bktype;
            ?>
');
                    <?php 
        } else {
            ?>
                            document.getElementById('ajax_message').innerHTML = '<?php 
            echo __('Updated successfully', 'wpdev-booking');
            ?>
';
                            jQuery('#ajax_message').fadeOut(1000);
                            document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            echo __('Updated successfully', 'wpdev-booking');
            ?>
</div>';
                            location.href='admin.php?page=<?php 
            echo WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME;
            ?>
wpdev-booking&booking_type=<?php 
            echo $bktype;
            ?>
&booking_id_selection=<?php 
            echo $my_booking_id;
            ?>
';
                    <?php 
        }
        ?>
                    </script> <?php 
    } else {
        if (count($my_dates) > 0) {
            //// For inserting NEW booking
            // Sending mail ///////////////////////////////////////////////////////
            $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_reservation_from_adress'));
            //'"'. 'Booking sender' . '" <' . $booking_form_show['email'].'>';
            $mail_recipient = htmlspecialchars_decode(get_bk_option('booking_email_reservation_adress'));
            //'"Booking receipent" <' .get_option('admin_email').'>';
            $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_reservation_subject'));
            $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_reservation_content'));
            $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject);
            $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body);
            $mail_body = str_replace('[bookingtype]', $bk_title, $mail_body);
            if (get_bk_option('booking_date_view_type') == 'short') {
                $my_dates_4_send = get_dates_short_format($my_dates4emeil);
            } else {
                $my_dates_4_send = change_date_format($my_dates4emeil);
            }
            $mail_body = str_replace('[dates]', $my_dates_4_send, $mail_body);
            $mail_body = str_replace('[check_in_date]', $my_check_in_date, $mail_body);
            $mail_body = str_replace('[check_out_date]', $my_check_out_date, $mail_body);
            $mail_body = str_replace('[id]', $booking_id, $mail_body);
            $mail_body = str_replace('[content]', $booking_form_show['content'], $mail_body);
            $mail_body = str_replace('[name]', $booking_form_show['name'], $mail_body);
            $mail_body = str_replace('[cost]', $my_cost, $mail_body);
            $mail_body = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body);
            $mail_body = str_replace('[moderatelink]', htmlspecialchars_decode('<a href="' . site_url() . '/wp-admin/admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking&booking_type=' . $bktype . '&moderate_id=' . $booking_id . '">' . __('here', 'wpdev-booking') . '</a>'), $mail_body);
            $mail_body = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body, $booking_id);
            if (isset($booking_form_show['secondname'])) {
                $mail_body = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body);
            }
            $mail_subject = str_replace('[name]', $booking_form_show['name'], $mail_subject);
            if (isset($booking_form_show['secondname'])) {
                $mail_subject = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject);
            }
            $mail_headers = "From: {$mail_sender}\n";
            $mail_headers .= "Content-Type: text/html\n";
            if (strpos($mail_recipient, '[visitoremeil]') !== false) {
                $mail_recipient = str_replace('[visitoremeil]', $booking_form_show['email'], $mail_recipient);
            }
            if (get_bk_option('booking_is_email_reservation_adress') != 'Off') {
                if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body, '*****@*****.**') === false) {
                    if ($is_send_emeils != 0) {
                        @wp_mail($mail_recipient, $mail_subject, $mail_body, $mail_headers);
                    }
                }
            }
            /////////////////////////////////////////////////////////////////////////
            if (get_bk_option('booking_is_email_newbookingbyperson_adress') == 'On') {
                $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_newbookingbyperson_adress'));
                //'"'. 'Booking sender' . '" <' . $booking_form_show['email'].'>';
                $mail_recipient = $booking_form_show['email'];
                $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_newbookingbyperson_subject'));
                $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_newbookingbyperson_content'));
                $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject);
                $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body);
                $mail_body = str_replace('[bookingtype]', $bk_title, $mail_body);
                if (get_bk_option('booking_date_view_type') == 'short') {
                    $my_dates_4_send = get_dates_short_format($my_dates4emeil);
                } else {
                    $my_dates_4_send = change_date_format($my_dates4emeil);
                }
                $mail_body = str_replace('[dates]', $my_dates_4_send, $mail_body);
                $mail_body = str_replace('[check_in_date]', $my_check_in_date, $mail_body);
                $mail_body = str_replace('[check_out_date]', $my_check_out_date, $mail_body);
                $mail_body = str_replace('[id]', $booking_id, $mail_body);
                $mail_body = str_replace('[content]', $booking_form_show['content'], $mail_body);
                $mail_body = str_replace('[name]', $booking_form_show['name'], $mail_body);
                $mail_body = str_replace('[cost]', $my_cost, $mail_body);
                $mail_body = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body);
                $mail_body = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body, $booking_id);
                if (isset($booking_form_show['secondname'])) {
                    $mail_body = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body);
                }
                $mail_subject = str_replace('[name]', $booking_form_show['name'], $mail_subject);
                if (isset($booking_form_show['secondname'])) {
                    $mail_subject = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject);
                }
                $mail_headers = "From: {$mail_sender}\n";
                $mail_headers .= "Content-Type: text/html\n";
                if (strpos($mail_recipient, '[visitoremeil]') !== false) {
                    $mail_recipient = str_replace('[visitoremeil]', $booking_form_show['email'], $mail_recipient);
                }
                if (strpos($mail_recipient, '@blank.com') === false) {
                    if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body, '*****@*****.**') === false) {
                        if ($is_send_emeils != 0) {
                            @wp_mail($mail_recipient, $mail_subject, $mail_body, $mail_headers);
                        }
                    }
                }
            }
        }
        do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $sdform);
        ?>
 <script type="text/javascript"> setReservedSelectedDates('<?php 
        echo $bktype;
        ?>
'); </script>  <?php 
    }
    // ReUpdate booking resource TYPE if its needed here
    if (!empty($dates)) {
        // check to have dates not empty
        make_bk_action('wpdev_booking_reupdate_bk_type_to_childs', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $sdform);
    }
}
Beispiel #26
0
 public function getLeadsChartData($period)
 {
     if (!DashboardCommon::is_su()) {
         $client_calls_where = " AND gsm_number IN (" . $this->get_gsm_number() . ") AND test_data=0\n                                    {$this->calls_data_limit_clause}\n                                    ORDER BY call_start DESC";
         $client_email_where = " AND client_id  IN ('" . implode('\',\'', $this->get_unbounce_ids()) . "')  AND test_data=0\n                                    ORDER BY email_date DESC";
     }
     $data = array();
     $period_days = array();
     $date_filter = "Y-m-d";
     if ($period == 'lifetime') {
         $period_days = getMonths($this->from, $this->to);
         $date_filter = "Y-m";
     } elseif ($period == 'last_30_days' || $period == 'last_7_days' || $period == 'yesterday' || $period == 'month' || $period == 'daily' || $period == 'today' || $period == 'this_month' || $period == 'custom' || $period == 'last_month') {
         $period_days = createDateRangeArray($this->from, $this->to);
     } else {
         $period_days = createDateRangeArray($this->from, $this->to);
     }
     if (!empty($period_days)) {
         foreach ($period_days as $date) {
             if ($date_filter === 'Y-m-d') {
                 $date_filtered = $date;
             } else {
                 $date_filtered = date_format($date, "{$date_filter}");
             }
             $q1 = "SELECT count(*) as  total_calls FROM calls WHERE call_start LIKE '%" . $date_filtered . "%' {$client_calls_where} ";
             $rc = DashboardCommon::db()->Execute($q1);
             $c_total = $rc->fields['total_calls'];
             if ($c_total == '') {
                 $c_total = 0;
             }
             $q2 = "SELECT count(*) as  total_emails FROM emails WHERE email_date LIKE '%" . $date_filtered . "%' {$client_email_where}";
             $re = DashboardCommon::db()->Execute($q2);
             $e_total = $re->fields['total_emails'];
             if ($e_total == '') {
                 $e_total = 0;
             }
             $sql_leads = "SELECT * , tcalls+temails as total_leads\n                    FROM\n                    (SELECT \n                        COUNT(DISTINCT  DATE_FORMAT(call_start,'%y-%m-%d') , gsm_number) as tcalls\n                        FROM calls \n                        WHERE\n                        call_start LIKE '%" . $date_filtered . "%' {$client_calls_where}\n                    ) as a , \n                    (SELECT \n                        COUNT(*) as temails\n                        FROM emails \n                        WHERE\n                        email_date LIKE '%" . $date_filtered . "%' {$client_email_where}\n                    ) as b";
             //echo $sql_leads; die();
             $res_leads = DashboardCommon::db()->Execute($sql_leads);
             $tot_leads = $res_leads->fields['total_leads'] != '' ? $res_leads->fields['total_leads'] : 0;
             $row = array('y' => $date_filtered, 'a' => $c_total, 'b' => $e_total, 'c' => $tot_leads);
             $data[] = $row;
         }
     }
     return $data;
 }
 $_POST['gwpm_starsign'] = rand(1, 26);
 $_POST['gwpm_user'] = '******';
 $_POST['gwpm_caste'] = 'Mudliyar';
 $_POST['gwpm_zodiac'] = rand(1, 12);
 $_POST['gwpm_contact_no'] = rand(1, 12) * 100000000 + 989898 + rand(5000, 10000);
 $gwpm_education['qualification'] = "" . rand(1, 4);
 $gwpm_education['qualification_other'] = "" . 'Other';
 $gwpm_education['specialization'] = "" . rand(1, 4);
 $gwpm_education['status'] = "" . rand(1, 4);
 $_POST['gwpm_education'] = $gwpm_education;
 $dynaKeys = getDynamicFieldKeys();
 foreach ($dynaKeys as $__keys) {
     echo "<br /> Dyna: " . $__keys;
     $_POST[$__keys] = "" . rand(1, 3);
 }
 $abt = createDateRangeArray('1980-10-01', '1985-10-05');
 $newdata = $abt[0];
 echo $newdata . "<br />";
 $_POST['gwpm_dob'] = $newdata;
 //	$profileObj = new GwpmProfileVO($_POST);
 $profileObj = new GwpmProfileVO($_POST, $dynaKeys);
 $profileObj->gwpm_profile_photo = $_FILES["gwpm_profile_photo"];
 $validateObj = $profileObj->validate();
 if (sizeof($validateObj) == 0) {
     $mymodel->updateUser($profileObj);
     echo __('success_message', 'Profile updated successfully!!' . '<br />');
 } else {
     echo __('Please correct the below fields: ' . '<br />');
     print_r($validateObj);
     echo "<>br />";
 }
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["yhxxwwp"] = "response";
     ${"GLOBALS"}["pxeqxzb"] = "adb";
     ${${"GLOBALS"}["pxeqxzb"]} = PearDatabase::getInstance();
     ${${"GLOBALS"}["yhxxwwp"]} = new Vtiger_Response();
     try {
         ${"GLOBALS"}["oiwytok"] = "destParts";
         ${"GLOBALS"}["tpetshnvd"] = "endDate";
         $iswounrnek = "result";
         $uobfcxfl = "endDate";
         $horlccannv = "max";
         ${"GLOBALS"}["bwjsfawphw"] = "max";
         ${${"GLOBALS"}["bibzqs"]} = $request->get("source");
         ${${"GLOBALS"}["bppobsjc"]} = $request->get("destination");
         $ophrsqnqox = "module_name";
         ${${"GLOBALS"}["woengridn"]} = date("Y-m-d", strtotime($request->get("startDate")));
         $qdolutxmeo = "instance";
         $pjnbbpuuqxo = "sourceParts";
         $hlftbibsr = "days";
         $wnpszmuoobf = "startDate";
         $hmvrqvo = "destination";
         ${"GLOBALS"}["ijyhdjitchvp"] = "source";
         ${$uobfcxfl} = date("Y-m-d", strtotime($request->get("endDate")));
         ${${"GLOBALS"}["urjerclfrbq"]} = $request->get("module_name");
         $pkfjjhq = "destParts";
         $mdkfudjveoo = "sourceParts";
         ${$mdkfudjveoo} = explode("__", ${${"GLOBALS"}["ijyhdjitchvp"]});
         ${"GLOBALS"}["qervoel"] = "startDate";
         ${${"GLOBALS"}["oiwytok"]} = explode("__", ${$hmvrqvo});
         ${$qdolutxmeo} = CRMEntity::getInstance(${$ophrsqnqox});
         $jdmekf = "endDate";
         $xtewmsf = "result";
         ${"GLOBALS"}["uwrtufgmq"] = "days";
         ${${"GLOBALS"}["tlujtnfudsoo"]} = "SELECT COUNT(*) as num, DATE(timestamp) as `date`\n                    FROM vtiger_wf_log\n                WHERE lastBlockId = " . ${$pjnbbpuuqxo}[1] . " AND lastBlockOutput = '" . ${${"GLOBALS"}["ecdsgnnepizb"]}[2] . "' AND blockID = '" . ${$pkfjjhq}[1] . "' AND timestamp >= '" . ${${"GLOBALS"}["qervoel"]} . " 00:00:00' AND timestamp <= '" . ${${"GLOBALS"}["tpetshnvd"]} . " 23:59:00' GROUP BY DATE(timestamp)";
         $jvkelzjdi = "interval";
         $iernywmknrr = "day";
         ${$iswounrnek} = $adb->query(${${"GLOBALS"}["tlujtnfudsoo"]});
         ${${"GLOBALS"}["ydwzvzcgkpv"]} = array();
         $amqwluuvjyg = "max";
         ${${"GLOBALS"}["kelygfmapmx"]} = 9999;
         ${${"GLOBALS"}["bwjsfawphw"]} = 0;
         ${${"GLOBALS"}["uwrtufgmq"]} = createDateRangeArray(${$wnpszmuoobf}, ${$jdmekf});
         ${"GLOBALS"}["crbuhjvng"] = "max";
         while (${${"GLOBALS"}["tvcadb"]} = $adb->fetch_array(${${"GLOBALS"}["rdqhjsrop"]})) {
             $zlmkdbsrt = "max";
             ${"GLOBALS"}["pwkkjdeyn"] = "row";
             ${${"GLOBALS"}["ydwzvzcgkpv"]}[${${"GLOBALS"}["tvcadb"]}["date"]] = ${${"GLOBALS"}["tvcadb"]}["num"];
             if (${${"GLOBALS"}["pwkkjdeyn"]}["num"] < ${${"GLOBALS"}["kelygfmapmx"]}) {
                 $qybesgi = "min";
                 $xewkelnygnh = "row";
                 ${$qybesgi} = ${$xewkelnygnh}["num"];
             }
             if (${${"GLOBALS"}["tvcadb"]}["num"] > ${$zlmkdbsrt}) {
                 ${"GLOBALS"}["fqjmvxecq"] = "row";
                 ${${"GLOBALS"}["jebwgsoqcau"]} = ${${"GLOBALS"}["fqjmvxecq"]}["num"];
             }
         }
         ${${"GLOBALS"}["rdqhjsrop"]} = array();
         foreach (${${"GLOBALS"}["hiokisn"]} as ${$iernywmknrr}) {
             ${"GLOBALS"}["mkcstfyyu"] = "day";
             if (isset(${${"GLOBALS"}["ydwzvzcgkpv"]}[${${"GLOBALS"}["mkcstfyyu"]}])) {
                 ${"GLOBALS"}["bzxmqyitlr"] = "data";
                 $ponccidnqdn = "day";
                 ${${"GLOBALS"}["rdqhjsrop"]}[] = array(date("d-M-Y", strtotime(${${"GLOBALS"}["gkqzyqt"]})), ${${"GLOBALS"}["bzxmqyitlr"]}[${$ponccidnqdn}]);
             } else {
                 ${"GLOBALS"}["jnnfrdtxydq"] = "day";
                 ${"GLOBALS"}["nqlunrvsrc"] = "result";
                 ${${"GLOBALS"}["nqlunrvsrc"]}[] = array(date("d-M-Y", strtotime(${${"GLOBALS"}["jnnfrdtxydq"]})), 0);
             }
         }
         if (count(${$hlftbibsr}) > 10) {
             $rbntpxsufr = "interval";
             ${$rbntpxsufr} = 7;
         } else {
             ${"GLOBALS"}["wkwenrq"] = "interval";
             ${${"GLOBALS"}["wkwenrq"]} = 1;
         }
         ${"GLOBALS"}["bgtxppfnvy"] = "min";
         if (${${"GLOBALS"}["crbuhjvng"]} > 200) {
             ${${"GLOBALS"}["wahhniepks"]} = 50;
         } elseif (${$horlccannv} > 100) {
             ${${"GLOBALS"}["wahhniepks"]} = 25;
         } elseif (${${"GLOBALS"}["jebwgsoqcau"]} > 50) {
             ${${"GLOBALS"}["wahhniepks"]} = 10;
         } elseif (${$amqwluuvjyg} >= 6) {
             $qkrnzmkcpyi = "Xinterval";
             ${$qkrnzmkcpyi} = 2;
         } else {
             $prtlep = "Xinterval";
             ${$prtlep} = 1;
         }
         ${${"GLOBALS"}["ydwzvzcgkpv"]} = array("Yinterval" => ${$jvkelzjdi}, "Xinterval" => ${${"GLOBALS"}["wahhniepks"]}, "min" => intval(${${"GLOBALS"}["bgtxppfnvy"]}), "max" => intval(${${"GLOBALS"}["jebwgsoqcau"]}), "data" => ${$xtewmsf});
         $response->setResult(array("success" => true, "data" => ${${"GLOBALS"}["ydwzvzcgkpv"]}));
     } catch (Exception $exp) {
         $response->setResult(array("success" => false, "error" => $exp->getMessage()));
     }
     $response->emit();
 }
$pending_dates = array();
$curret_user_id = $_SESSION['user_id'];
$tot_hrs = 0;
$holidays = array();
$query = "SELECT date FROM amz_holidays where status='1' AND deleted='0'";
$result = $conn->runsql($query, $dbcon);
while ($row = mysqli_fetch_object($result)) {
    $holidays[] = $row->date;
}
$query = "SELECT user_id,user_mail,last_entry_on,create_date FROM amz_login where user_id='{$curret_user_id}'";
$result = $conn->runsql($query, $dbcon);
while ($row = mysqli_fetch_object($result)) {
    $current_user = $row->user_id;
    $last_entry_date = $row->last_entry_on == "" ? $row->create_date : $row->last_entry_on;
    $today_date = date('Y-m-d', $_SERVER['REQUEST_TIME']);
    $aryDates = createDateRangeArray($last_entry_date, $today_date);
    $size = sizeof($aryDates);
    for ($i = 0; $i < $size; $i++) {
        if (!in_array($aryDates[$i], $holidays)) {
            $single_date = $aryDates[$i];
            $time_diff = getTimes($single_date, $today_date);
            if ($time_diff >= 24) {
                $tot_hrs = 0;
                $query_1 = "SELECT time FROM user_tasks WHERE date='{$single_date}' AND user_id='{$current_user}'";
                $result_1 = $conn->runsql($query_1, $dbcon);
                if (mysqli_num_rows($result_1)) {
                    while ($result_row_1 = mysqli_fetch_object($result_1)) {
                        //$tot_hrs = $tot_hrs + $result_row_1->time;
                        $tot_hrs += strtotime($result_row_1->time) - strtotime("00:00:00");
                    }
                    //echo $tot_hrs;
 function dailyreport()
 {
     $search = $this->search_post($_POST);
     $startdate = $_GET['startdate'];
     $enddate = $_GET['enddate'];
     //-- generate daily graph data --//
     if ($startdate == '' && $enddate == '') {
         $startdate = date('d-m-Y', strtotime(date('Y-m-01')));
         $enddate = date('Y-m-d');
     }
     if ($startdate == '') {
         $startdate = date('d-m-Y', strtotime(date('Y-m-01')));
     }
     if ($enddate == '') {
         $enddate = date('Y-m-d');
     }
     $dateRange = createDateRangeArray($startdate, $enddate);
     //-- helper to get date range
     $dailyreport = $this->Ads_analytics_model->getDailyReport($dateRange);
     echo json_encode($dailyreport);
     die;
     //-----------------------------//
 }