public function __construct($month, $year)
 {
     parent::__construct();
     $this->year = $year;
     $this->month = $month;
     $this->daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
 }
 function GetEventsForMonth($year, $month, $employeeId, $categoryId)
 {
     $monthStartString = $year . '-' . $month . '-1' . ' 00:00:00';
     $totalDays = cal_days_in_month(CAL_GREGORIAN, $month, $year);
     $monthEndString = $year . '-' . $month . '-' . $totalDays . ' 23:59:59';
     return $this->GetEventsForTimePeriod($monthStartString, $monthEndString, $employeeId, $categoryId);
 }
 function make_days_array($year, $month)
 {
     // Calculate the number of days in the selected month
     $num_days_month = cal_days_in_month(CAL_GREGORIAN, $month, $year);
     // Make $this->days array containing the Day Number and Day Number in the selected month
     for ($i = 1; $i <= $num_days_month; $i++) {
         // Work out the Day Name ( Monday, Tuesday... ) from the $month and $year variables
         $d = mktime(0, 0, 0, $month, $i, $year);
         // Create the array
         $this->days[] = array("daynumber" => $i, "dayname" => date("l", $d));
     }
     /*	
     Sample output of the $this->days array:
     
     [0] => Array
             (
                 [daynumber] => 1
                 [dayname] => Monday
             )
     
         [1] => Array
             (
                 [daynumber] => 2
                 [dayname] => Tuesday
             )
     */
     $this->make_blank_start($year, $month);
     $this->make_blank_end($year, $month);
 }
Example #4
0
 public static function days($month, $year = FALSE)
 {
     if ($year === FALSE) {
         $year = date('Y');
     }
     return cal_days_in_month(CAL_GREGORIAN, $month, $year);
 }
 public function actionMonthStorage()
 {
     $dates = explode('-', $_POST['dates']);
     $depId = $_POST['depId'];
     $number = cal_days_in_month(CAL_GREGORIAN, $dates[1], $dates[0]);
     $realized = array();
     $expense = new Expense();
     $expenses = array();
     $startCount = array();
     $endCount = array();
     $depRealize = new DepFaktura();
     $inexp = new Expense();
     $balance = new Balance();
     for ($i = 1; $i <= $number; $i++) {
         $tempDate = $dates[0] . "-" . $dates[1] . "-" . $i;
         $listDate[$i] = $tempDate;
         $realized[$tempDate] = $depRealize->getDepRealizesSumm($tempDate, $depId);
         $expenses[$tempDate] = $expense->getDepCost($depId, $tempDate);
         $tempBalance = $balance->getDepBalanceSumm($tempDate, $depId);
         $startCount[$tempDate] = $tempBalance[0];
         $endCount[$tempDate] = $tempBalance[1];
         $curEndCount[$tempDate] = $tempBalance[2];
     }
     $this->renderPartial('monthStorage', array('tempDate' => $listDate, 'realized' => $realized, 'expenses' => $expenses, 'startCount' => $startCount, 'endCount' => $endCount, 'curEndCount' => $curEndCount, 'depId' => $depId));
 }
 public function visitorAction()
 {
     $request = $this->getRequest();
     $session = $request->getSession();
     $ip = $_SERVER['REMOTE_ADDR'];
     $time = time();
     $session = $this->getRequest()->getSession();
     $session_visitor = $session->get('visitor');
     $session_visitor_day = $session->get('visitor_day');
     if (!isset($session_visitor_day)) {
         $session->set("visitor_day", $time);
     } else {
         if (!isset($session_visitor)) {
             // insert him into the database and create a session
             $this->createVisitor($ip, $time);
             $session->set("visitor", $time);
         } else {
             //Check for daily stats first
             if (!($session_visitor > time() - 86400 * cal_days_in_month(CAL_GREGORIAN, date("m"), date("Y")))) {
                 $session->set("visitor_day", $time);
             }
             if (!($session_visitor > time() - 600)) {
                 $this->createVisitor($ip, $time);
                 $session->set("visitor", $time);
             }
         }
     }
     $session->save();
     session_write_close();
     return new Response(json_encode(array("success" => true)));
 }
Example #7
0
 function get_billing_info($account_id = SES_COMP)
 {
     App::import('Model', 'UserSubscription');
     $usersub = new UserSubscription();
     $user_sub = $usersub->find('first', array('conditions' => array('company_id' => $account_id), 'order' => 'id DESC'));
     $pmonth = date('m', strtotime('-1 month', strtotime($user_sub['UserSubscription']['next_billing_date'])));
     $pyear = date('Y', strtotime('-1 month', strtotime($user_sub['UserSubscription']['next_billing_date'])));
     $mdays = cal_days_in_month(CAL_GREGORIAN, $pmonth, $pyear);
     if (strtotime($user_sub['UserSubscription']['sub_start_date']) + $mdays * 24 * 60 * 60 < strtotime($user_sub['UserSubscription']['next_billing_date'])) {
         $dt_chk = date('Y-m-d H:i:s', strtotime($user_sub['UserSubscription']['next_billing_date']) - $mdays * 24 * 60 * 60);
     } else {
         $dt_chk = $user_sub['UserSubscription']['sub_start_date'];
     }
     App::import('Model', 'CompanyUser');
     $compuser = new CompanyUser();
     //$counter = $compuser->find('count',array('conditions'=>array('company_id'=>$account_id,'created <'=>$dt_chk,'(is_active=1 OR is_active=2)')));
     //$user_info =  $compuser->find('all',array('conditions'=>array('company_id'=>$account_id,'created >'=>$dt_chk,'(is_active=1 OR is_active=2)'),'group'=>array('DATE(created)'),'fields'=>array('DATE(created) AS dt','DATE(modified) AS mfd_dt','COUNT(id) as cnt','SUM(est_billing_amt) AS amnt')));
     //$delted_users =  $compuser->find('all',array('conditions'=>array('company_id'=>$account_id,'is_active'=>3,'OR'=>array('created >'=>$dt_chk,'modified >'=>$dt_chk)),'group'=>array('dt','DATE(modified)'),'fields'=>array("IF((created > '".$dt_chk."'),DATE(created),'".date('Y-m-d',strtotime($dt_chk))."') AS dt",'DATE(modified) AS mfd_dt','COUNT(id) as cnt','SUM(est_billing_amt) AS amnt')));
     $counter = $compuser->find('count', array('conditions' => array('company_id' => $account_id, 'is_active' => 1)));
     $invited_users = $compuser->find('count', array('conditions' => array('company_id' => $account_id, 'is_active' => 2)));
     $disabled_users = $compuser->find('count', array('conditions' => array('company_id' => $account_id, 'is_active' => 0, 'billing_end_date >= ' => GMT_DATE)));
     $deleted_users = $compuser->find('count', array('conditions' => array('company_id' => $account_id, 'is_active' => 3, 'billing_end_date >= ' => GMT_DATE)));
     //$user_info =  $compuser->find('all',array('conditions'=>array('company_id'=>$account_id,'created >'=>$dt_chk,'(is_active=1 OR is_active=2)'),'group'=>array('DATE(created)'),'fields'=>array('DATE(created) AS dt','DATE(modified) AS mfd_dt','COUNT(id) as cnt','SUM(est_billing_amt) AS amnt')));
     //$delted_users =  $compuser->find('all',array('conditions'=>array('company_id'=>$account_id,'is_active'=>3,'OR'=>array('created >'=>$dt_chk,'modified >'=>$dt_chk)),'group'=>array('dt','DATE(modified)'),'fields'=>array("IF((created > '".$dt_chk."'),DATE(created),'".date('Y-m-d',strtotime($dt_chk))."') AS dt",'DATE(modified) AS mfd_dt','COUNT(id) as cnt','SUM(est_billing_amt) AS amnt')));
     //$user_info['previous_users'] =$counter;
     //$user_info['delted_users'] =$delted_users;
     $user_info['active_users'] = $counter;
     $user_info['invited_users'] = $invited_users;
     $user_info['disabled_users'] = $disabled_users;
     $user_info['deleted_users'] = $deleted_users;
     return $user_info;
     //echo "<pre>";print_r($user_info);exit;
 }
 public function months()
 {
     $folder_params = $this->fetchParam("folders");
     $year_params = $this->fetchParam("year");
     $folders = $this->cleanFoldersList($folder_params);
     $filenames = $this->scanDirectory($folders);
     $sort = $this->fetchParam("sort");
     //extract all years from all filenames
     foreach ($filenames as $file) {
         $year = substr($file, 0, 4);
         $month = substr($file, 5, 2);
         if ($year == $year_params) {
             $months_array[] = $month;
         }
     }
     //get unique year entries and counts.
     $months = array_unique($months_array);
     rsort($months);
     if ($sort == 'asc') {
         $months = array_reverse($months);
     }
     $counts = array_count_values($months_array);
     $total = array_sum($counts);
     $return_array['total'] = $total;
     //create return array
     foreach ($months as $month) {
         $return_array['months'][] = array('month' => $month, 'month_text' => date('F', mktime(0, 0, 0, $month, 10)), 'year' => $year_params, 'count' => $counts[$month], 'days_in_month' => cal_days_in_month(CAL_GREGORIAN, $month, $year_params));
     }
     return $return_array;
 }
Example #9
0
 public function VisionAccueilAction(Request $request, $month, $year)
 {
     if ($this->getUser()->getAgent()->getService()->getId() != 13) {
         throw new AccessDeniedException("Vous n'êtes pas autorisé à acceder à cette page");
     }
     //récupération EntityManager
     $em = $this->getDoctrine()->getManager();
     //récupération de tout les agents
     $repositoryUser = $em->getRepository('OCUserBundle:User');
     $users = $repositoryUser->findAll();
     $repositoryEvent = $em->getRepository("OCCalendrierBundle:Event");
     $events = $repositoryEvent->findAbsenceByMonthAndYear($month, $year);
     $repositoryHSF = $em->getRepository("OCCalendrierBundle:HeureSupFrac");
     $HSF = $repositoryHSF->findByHSFMonthAndYear($month, $year);
     $repositoryServices = $em->getRepository("OCAgentBundle:Service");
     $services = $repositoryServices->findAll();
     $repositoryCategory = $em->getRepository("OCCalendrierBundle:Category");
     $Categories = $repositoryCategory->findAll();
     $repositoryCategoryhsf = $em->getRepository("OCCalendrierBundle:CategoryHSF");
     $Categorieshsf = $repositoryCategoryhsf->findAll();
     $JoursDansMois = cal_days_in_month(CAL_GREGORIAN, $month, $year);
     $defaultData = array('message' => 'Type your message here');
     $form = $this->createFormBuilder($defaultData)->add('month', 'choice', array('choices' => array('01' => 'Janvier', '02' => 'Fevrier', '03' => 'Mars', '04' => 'Avril', '05' => 'Mai', '06' => 'Juin', '07' => 'Juillet', '08' => 'Aout', '09' => 'Septembre', '10' => 'Octobre', '11' => 'Novembre', '12' => 'Decembre')))->add('year', 'choice', array('choices' => array(date('Y') - 2 => date('Y') - 2, date('Y') - 1 => date('Y') - 1, date('Y') => date('Y'), date('Y') + 1 => date('Y') + 1), 'preferred_choices' => array(date('Y'))))->add('AllerA', 'submit')->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $JoursDansMois = cal_days_in_month(CAL_GREGORIAN, $form["month"]->getData(), $form["year"]->getData());
         return $this->redirect($this->generateUrl('oc_vision_cla_homepage', array('month' => $form["month"]->getData(), 'year' => $form["year"]->getData())));
     }
     //var_dump($events[1]);
     return $this->render("OCVisionCLABundle:VisionCla:VisionClaAccueil.html.twig", array('month' => $month, 'year' => $year, 'events' => $events, 'tabHSF' => $HSF, 'users' => $users, 'services' => $services, 'Categories' => $Categories, 'Categorieshsf' => $Categorieshsf, 'JoursDansMois' => $JoursDansMois, 'form' => $form->createView(), 'user' => $this->getUser()));
 }
Example #10
0
function inputTanggal($dn, $val = "0000-00-00", $cb = "")
{
    global $MNTHN;
    $tgl = explode("-", $val);
    $s = "";
    if (intval($tgl[1]) != 0) {
        $dim = cal_days_in_month(CAL_GREGORIAN, intval($tgl[1]), intval($tgl[0])) + 1;
    } else {
        $dim = 32;
    }
    $s .= "<input type=\"hidden\" id=\"" . $dn . "\" name=\"" . $dn . "\" value=\"" . $val . "\" />";
    $s .= "<input type=\"hidden\" id=\"" . $dn . "f\" name=\"" . $dn . "f\" value=\"" . $val . "\" />";
    $s .= "<input type=\"hidden\" id=\"" . $dn . "s\" name=\"" . $dn . "s\" value=\"" . $val . "\" />";
    $s .= "<select class=\"iSelect\" id=\"" . $dn . "_m\" name=\"" . $dn . "_m\" onchange=\"inputdateChange('" . $dn . "');" . $cb . "\" onfocus=\"this.className='iSelectx'\" onblur=\"this.className='iSelect'\"><option value=\"0\">month:</option>";
    for ($kk = 1; $kk <= 12; $kk++) {
        $s .= "<option value=\"" . $kk . "\" " . ($kk == $tgl[1] ? "selected" : "") . " >" . $MNTHN[$kk] . "</option>";
    }
    $s .= "</select>";
    $s .= "<select class=\"iSelect\" id=\"" . $dn . "_d\" name=\"" . $dn . "_d\" style=\"margin-left:2px\" onchange=\"inputdateChange('" . $dn . "');" . $cb . "\" onfocus=\"this.className='iSelectx'\" onblur=\"this.className='iSelect'\"><option value=\"0\">date:</option>";
    for ($kk = 1; $kk < $dim; $kk++) {
        $s .= "<option value=\"" . $kk . "\" " . ($kk == $tgl[2] ? "selected" : "") . " >" . $kk . "</option>";
    }
    $s .= "</select> , ";
    $s .= "<select class=\"iSelect\" id=\"" . $dn . "_y\" name=\"" . $dn . "_y\" style=\"margin-left:2px\" onchange=\"inputdateChange('" . $dn . "');" . $cb . "\" onfocus=\"this.className='iSelectx'\" onblur=\"this.className='iSelect'\"><option value=\"0\">year:</option>";
    for ($kk = intval(date("Y")) + 2; $kk >= 1945; $kk--) {
        $s .= "<option value=\"" . $kk . "\" " . ($kk == $tgl[0] ? "selected" : "") . " >" . $kk . "</option>";
    }
    $s .= "</select>";
    return $s;
}
Example #11
0
 public function getBudgetData($app, $year = 2016, $month = 8)
 {
     $startDate = $year . "/" . $month . "/1";
     $endDate = $year . "/" . ($month + 1) . "/1";
     $budgets = $this->db->query($this->qb->table($this->table)->where("start_date", ">=", $startDate)->andWhere("start_date", "<", $endDate)->andWhere("user_id", "=", $app->auth->user_id)->get())->result();
     foreach ($budgets as $budget) {
         $budgetTags = $app->BudgetTag->find('all', ["where" => ["bud_id", "=", $budget->id]]);
         $tags = [];
         foreach ($budgetTags as $tag) {
             $tags[] = $app->Tags->find('all', ["where" => ["id", "=", $tag->tag_id]]);
         }
         $spent = $app->ExpTags->expTagsTotalSpent($app->auth->user_id, $startDate, $endDate, $tags);
         $exptags = [];
         foreach ($tags as $tagone) {
             foreach ($tagone as $tag) {
                 $tagInfo = $app->Tags->find();
                 $amount = (int) $this->db->query("SELECT Sum(exp.cost ) as total FROM exp_tags as tag,expenses as exp where tag_id = ? and exp.exp_id = tag.exp_id and  exp.date >= ? and exp.date < ? and exp.user_id = ?", [$tag->id, $startDate, $endDate, $app->auth->user_id])->first()->total;
                 if ($amount > 0) {
                     $exptags[$tag->name] = $amount;
                 }
             }
         }
         $budgetDate = new Carbon($budget->start_date, 'Australia/Perth');
         //perth time zone
         $budget->tags = $exptags;
         $budget->spent = $spent;
         $budget->spentPercentage = number_format($spent / $budget->amount * 100, 2, '.', ',');
         $budget->future = Carbon::now('Australia/Perth')->lt($budgetDate);
         $budget->spendingLeft = $budget->future == true ? ($budget->amount - $spent) / cal_days_in_month(CAL_GREGORIAN, $month, $year) : number_format(($budget->amount - $spent) / (cal_days_in_month(CAL_GREGORIAN, $month, $year) - (int) date('j')), 2, '.', ',');
         $budget->expired = Carbon::now('Australia/Perth')->gt($budgetDate->addMonth());
         $budget->saved = $budget->amount - $spent > 0 ? number_format($budget->amount - $spent, 2, '.', ',') : number_format($spent - $budget->amount, 2, '.', ',');
     }
     return $budgets;
 }
Example #12
0
function getMonthDays($days)
{
    $workdays = array();
    $type = CAL_GREGORIAN;
    $month = date('n');
    // Month ID, 1 through to 12.
    $year = date('Y');
    // Year in 4 digit 2009 format.
    $day_count = cal_days_in_month($type, $month, $year);
    // Get the amount of days
    //loop through all days
    for ($i = 1; $i <= $day_count; $i++) {
        $date = $year . '/' . $month . '/' . $i;
        //format date
        $get_name = date('l', strtotime($date));
        //get week day
        $day_name = substr($get_name, 0, 3);
        // Trim day name to 3 chars
        //if not a weekend add day to array
        if ($day_name != 'Sun' && $day_name != 'Sat') {
            $workdays['workdays'][] = $i;
        } else {
            $workdays['weekends'][] = $i;
        }
    }
    return $workdays[$days];
}
function buildCalendar($month, $year)
{
    // It's not generally a good idea to use global variables but it works
    global $names;
    $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
    $firstDayOfMonth = mktime(0, 0, 0, $month, 1, $year);
    // -1 is to make the day of week start from 0 (so that it is more natural to work with, using arrays)
    $dayOfWeek = getdate($firstDayOfMonth)["wday"] - 1;
    $calendar = "<table class=\"calendar\">\n        <caption>" . $names["months"][$month - 1] . "</caption><thead><tr>";
    foreach ($names["days"] as $day) {
        $calendar .= "<th class=\"header\">" . $day . "</th>";
    }
    $currentDay = 1;
    $calendar .= "</tr></thead><tbody><tr>";
    if ($dayOfWeek > 0) {
        $calendar .= "<td colspan=\"" . $dayOfWeek . "\"></td>";
    }
    while ($currentDay <= $daysInMonth) {
        if ($dayOfWeek == 7) {
            $dayOfWeek = 0;
            $calendar .= "</tr><tr>";
        }
        $calendar .= "<td>" . $currentDay . "</td>";
        $currentDay++;
        $dayOfWeek++;
    }
    if ($dayOfWeek != 7) {
        $calendar .= "<td colspan=\"" . (7 - $dayOfWeek) . "\"></td>";
    }
    $calendar .= "</tr></tbody></table>";
    return $calendar;
}
function pc_get_days_in_month()
{
    global $wp_locale;
    $month = date('n');
    $day_in_month = cal_days_in_month(CAL_GREGORIAN, $month, date('Y'));
    return $days_in_month;
}
Example #15
0
 public function render()
 {
     // metoda koja iscrtava kalendar
     $start = date('w', mktime(0, 0, 0, $this->month, 1, $this->year));
     // pozicija prvoj u mesecu koji se crta
     $days_in_month = cal_days_in_month(CAL_GREGORIAN, $this->month, $this->year);
     // broj dana u mesec koji se crta
     $same_week = 7;
     // promenljiva vodi računa o kraju nedelje
     echo "<table>";
     echo "<tr><td>Mesec: </td><th id='month-title'>{$this->month}</th><td>Godina: </td><th id='year-title'>{$this->year}</th></tr>";
     echo "<tr><td>Nedlja</td><td>Ponedeljak</td><td>Utorak</td><td>Sreda</td><td>Četvrtak</td><td>Petak</td><td>Subota</td><tr>";
     echo "<tr>";
     for ($i = 0; $i < $start; $i++) {
         // prazna polja pre prvog u mesecu
         echo "<td></td>";
         $same_week--;
     }
     for ($i = 1; $i <= $days_in_month; $i++) {
         if ($i == $this->date->format('j') && $this->month == $this->date->format('m') && $this->year == $this->date->format('Y')) {
             echo "<td id='today'>{$i}</td>";
             // današnji dan dobija id "today"
         } else {
             echo "<td>{$i}</td>";
         }
         $same_week--;
         if (!$same_week) {
             // ukoliko je kraj nedelje, novi red
             echo "</tr><tr>";
             $same_week = 7;
         }
     }
     echo "</tr></table>";
 }
Example #16
0
 public function indexAction()
 {
     if (!$this->getUser()) {
         return new RedirectResponse($this->generateUrl('schedule_login'));
     }
     // собрать календарь
     $arr_year = range(2012, 2017);
     if (isset($_GET['current_month']) and isset($_GET['current_year'])) {
         $current_datetime = date('d.m.Y', strtotime('01.' . $_GET['current_month'] . '.' . $_GET['current_year']));
     } else {
         $current_datetime = date('d.m.Y');
     }
     $current_time = strtotime($current_datetime);
     $current_month = date('F', strtotime($current_datetime));
     $current_year = date('Y', strtotime($current_datetime));
     $prev_month = strtotime($current_datetime . ' -1 month');
     $next_month = strtotime($current_datetime . ' +1 month');
     $dayInMonth = cal_days_in_month(CAL_GREGORIAN, date('m', $current_time), date('Y', $current_time));
     $firstDayMonth = date('N', strtotime('01-' . date('m-Y', $current_time)));
     $dateInPrevMonth = array();
     if ($firstDayMonth != 1) {
         $dayInPrevMonth = cal_days_in_month(CAL_GREGORIAN, date('m', $prev_month), date('Y', $prev_month));
         for ($i = $dayInPrevMonth; $i > $dayInPrevMonth - ($firstDayMonth - 1); $i--) {
             $dateInPrevMonth[$i] = $i;
         }
         ksort($dateInPrevMonth);
     }
     // собрать записи
     $em = $this->getDoctrine()->getManager();
     $events = $em->getRepository('ScheduleBundle:Event')->getEventsByMonth($current_time, true);
     // вывод
     return $this->render('ScheduleBundle::homepage.html.twig', array('prev_month' => $prev_month, 'next_month' => $next_month, 'current_datetime' => $current_datetime, 'current_month' => $current_month, 'current_year' => $current_year, 'arr_year' => $arr_year, 'dateInPrevMonth' => $dateInPrevMonth, 'dayInMonth' => $dayInMonth, 'events' => $events));
 }
Example #17
0
 function get_billing_info($account_id = SES_COMP)
 {
     App::import('Model', 'UserSubscription');
     $usersub = new UserSubscription();
     $user_sub = $usersub->find('first', array('conditions' => array('company_id' => $account_id), 'order' => 'id DESC'));
     $pmonth = date('m', strtotime('-1 month', strtotime($user_sub['UserSubscription']['next_billing_date'])));
     $pyear = date('Y', strtotime('-1 month', strtotime($user_sub['UserSubscription']['next_billing_date'])));
     $mdays = cal_days_in_month(CAL_GREGORIAN, $pmonth, $pyear);
     $secondsInYear = $mdays * 24 * 60 * 60;
     $nextBillingDate = strtotime($user_sub['UserSubscription']['next_billing_date']);
     $subscriptionStartTime = strtotime($user_sub['UserSubscription']['sub_start_date']);
     if ($subscriptionStartTime + $secondsInYear < $nextBillingDate) {
         $dt_chk = date('Y-m-d H:i:s', $nextBillingDate - $secondsInYear);
     } else {
         $dt_chk = $user_sub['UserSubscription']['sub_start_date'];
     }
     App::import('Model', 'CompanyUser');
     $compuser = new CompanyUser();
     $counter = $compuser->find('count', array('conditions' => array('company_id' => $account_id, 'is_active' => 1)));
     $invited_users = $compuser->find('count', array('conditions' => array('company_id' => $account_id, 'is_active' => 2)));
     $disabled_users = $compuser->find('count', array('conditions' => array('company_id' => $account_id, 'is_active' => 0, 'billing_end_date >= ' => GMT_DATE)));
     $deleted_users = $compuser->find('count', array('conditions' => array('company_id' => $account_id, 'is_active' => 3, 'billing_end_date >= ' => GMT_DATE)));
     $user_info['active_users'] = $counter;
     $user_info['invited_users'] = $invited_users;
     $user_info['disabled_users'] = $disabled_users;
     $user_info['deleted_users'] = $deleted_users;
     return $user_info;
 }
Example #18
0
 function __construct($month = null, $year = null)
 {
     $this->month = $month | date('n');
     $this->year = $year | date('Y');
     $this->dim = cal_days_in_month(CAL_GREGORIAN, $this->month, $this->year);
     $this->msw = jddayofweek(cal_to_jd(CAL_GREGORIAN, $this->month, 1, $this->year));
 }
 public function getCalender($year, $month, $NewsObj)
 {
     //指定した月の最初の曜日を取得
     $sdate = date('w', strtotime($year . $month . "01"));
     //月の最初の曜日分を埋める
     $calendar = array();
     for ($y = 0; $y < $sdate; $y++) {
         $calendar[] = array('k' => 0, 'v' => 0);
     }
     $alldate = cal_days_in_month(CAL_GREGORIAN, $month, $year);
     $sql = "select DATE(newsdate) as newsdate from news where newsdate between '" . $year . "-" . $month . "-01 00:00:00' and '" . $year . "-" . $month . "-" . $alldate . " 23:59:59'";
     $alldata = $NewsObj->query($sql);
     $allcaldate = array();
     foreach ($alldata as $data) {
         $date = new DateTime($data[0]['newsdate']);
         $allcaldate[$date->format('j')] = $date->format('j');
     }
     ksort($allcaldate);
     //--------------------
     for ($x = 1; $x <= $alldate; $x++) {
         $z = 0;
         if (in_array($x, $allcaldate)) {
             $day = sprintf('%02d', $x);
             $z = '2014' . $month . $day;
         }
         $calendar[] = array('k' => $x, 'v' => $z);
     }
     return $calendar;
 }
Example #20
0
 public function __construct($cellNumber, $year, $month, $isForLabel)
 {
     $this->number = $cellNumber;
     $this->year = (int) $year;
     $this->month = (int) $month;
     $this->isLabelCell = $isForLabel;
     $this->numberOfDaysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
 }
Example #21
0
function print_daily_employee_by_month($month, $year)
{
    global $daily_employee;
    $numOfDays = cal_days_in_month(CAL_GREGORIAN, $month, $year);
    for ($day = 1; $day <= $numOfDays; $day++) {
        print_daily_employee_by_date($month, $day, $year);
    }
}
 function getAttendanceListByMonth($year, $month, $class_id)
 {
     $range_start = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
     $range_end = date('Y-m-d', mktime(0, 0, 0, $month, cal_days_in_month(CAL_GREGORIAN, $month, $year), $year));
     $childs = $this->db->select('v_p.name AS program_type, sc.dob AS dob, sc.id as child_id ,sc.child_key as nric, sc.child_status, sc.name as child_name, sc.alias, scc.class_id as class_id ')->distinct()->from(IMS_DB_PREFIX . 'child as sc')->join(IMS_DB_PREFIX . 'child_class as scc', 'sc.id = scc.child_id')->join(IMS_DB_PREFIX . 'variables as v_p', 'v_p.id = sc.program_type', 'left')->where('scc.class_id', $class_id)->where("NOT( date(scc.start_date) > date('{$range_end}') OR date(scc.end_date) <= date('{$range_start}') )")->order_by('sc.name')->get()->result();
     $attendance = $this->db->select('c.name as child_name, c.alias,c.id as child_id,cc.class_id,c.child_key as nric,  d.date as date, ac.present, ac.remark, a.attendance_type, a.attendance_taken,  cc.*')->from(IMS_DB_PREFIX . 'child as c')->join(IMS_DB_PREFIX . 'child_class as cc', 'c.id = cc.child_id')->join(IMS_DB_PREFIX . 'attendance_child as ac', 'c.id = ac.child_id', 'left')->join(IMS_DB_PREFIX . 'attendance as a', 'ac.attendance_id = a.id')->join(IMS_DB_PREFIX . 'day as d', 'a.day_id=d.id', 'left')->where('cc.class_id', $class_id)->where("( year(d.date) ='" . $year . "' AND month(d.date) ='" . $month . "' )")->where("NOT( date(cc.start_date) > date('{$range_end}') OR date(cc.end_date) <= date('{$range_start}') )")->order_by('c.name')->get()->result();
     return array('childs' => $childs, 'attendance' => $attendance);
 }
Example #23
0
function displayDaysOptionByMouth($intMonth, $year = null)
{
    if ($year == null) {
        $year = date("Y", time());
    }
    $number = cal_days_in_month(CAL_GREGORIAN, $intMonth, $year);
    return intval($number);
}
Example #24
0
function days_in_month($year, $month)
{
    if (!function_exists('cal_days_in_month')) {
        return date('t', mktime(0, 0, 0, $month + 1, 0, $year));
    } else {
        return cal_days_in_month(CAL_GREGORIAN, $month, $year);
    }
}
Example #25
0
 public function info($datetime = null)
 {
     if (DevValue::isNull($datetime)) {
         return $this->_data;
     }
     $timestamp = $this->timestamp($datetime);
     $today = array();
     $count = 0;
     $today = getdate($timestamp);
     $timestamp2 = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
     $first = getdate($timestamp2);
     $sd = $today['mday'];
     $tsd = 28;
     $numdays = cal_days_in_month(CAL_GREGORIAN, $today['mon'], $today['year']);
     $sm = isset($sm) && is_numeric($sm) ? $sm : '';
     $sy = isset($sy) && is_numeric($sy) ? $sy : '';
     if ($sm <= 12 && $sm >= 0 && $sy != '') {
         $jday = juliantojd($sm, $sd, $sy);
         $timestamp = jdtounix($jday);
         $today = getdate($timestamp);
         $numdays = cal_days_in_month(CAL_GREGORIAN, $today['mon'], $today['year']);
         $timestamp2 = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
         $first = getdate($timestamp2);
     }
     $last_month = $today['mon'] - 1;
     if ($last_month < 1) {
         $last_month = 11;
         $last_year = $today['year'] - 1;
     } else {
         $last_year = $today['year'];
     }
     $next_month = $today['mon'] + 1;
     if ($next_month >= 12) {
         $next_month = 1;
         $next_year = $today['year'] + 1;
     } else {
         $next_year = $today['year'];
     }
     $date = array();
     $date['day'] = (int) $sd;
     $date['firstweekday'] = $first['wday'];
     $date['year'] = (int) $today['year'];
     $date['lastyear'] = (int) $last_year;
     $date['nextyear'] = (int) $next_year;
     $date['month'] = (int) $today['mon'];
     $date['lastmonth'] = (int) $last_month;
     $date['nextmonth'] = (int) $next_month;
     $date['daysinmonth'] = (int) $numdays;
     $date['second'] = (int) $today['seconds'];
     $date['minute'] = (int) $today['minutes'];
     $date['hour'] = (int) $today['hours'];
     $date['timestamp'] = $today[0];
     $date['timezone'] = '';
     $date['offset'] = '';
     // $this->assign($date);
     //Phew! that was a lot of work!
     return $date;
 }
Example #26
0
 public function indexAction()
 {
     if ($this->apartmentStatus == Objects::PRODUCT_STATUS_DISABLED) {
         $this->redirect()->toRoute('apartment/general', ['apartment_id' => $this->apartmentId]);
     }
     /*
      * @todo move out this
      */
     $weekDays = array('Sunday' => 0, 'Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6);
     // get main params from route, month and year
     $year = $this->params()->fromRoute('year', 0);
     $month = $this->params()->fromRoute('month', 0);
     if ($year && $month) {
         // do checks for given month and year
         $roleManager = 'no';
         $auth = $this->getServiceLocator()->get('library_backoffice_auth');
         if ($auth->hasRole(Roles::ROLE_APARTMENT_INVENTORY_MANAGER)) {
             $roleManager = 'yes';
         }
         $givenMonthName = date("F", mktime(0, 0, 0, $month, 10));
         // get given month name
         $firstDayOfGivenMonthTimestamp = strtotime('first day of ' . $year . '-' . $month);
         // get first day of given month in miliseconds
         $firstDayOfGivenMonthDate = getdate($firstDayOfGivenMonthTimestamp);
         // get date array from timestamp
         $dayOfWeek = $weekDays[$firstDayOfGivenMonthDate['weekday']];
         // get day of week for given month first day to correctly render calendar
         $givenMonthDaysCount = cal_days_in_month(CAL_GREGORIAN, $month, $year);
         /** @var $rateService \DDD\Service\Apartment\Rate */
         $rateService = $this->getServiceLocator()->get('service_apartment_rate');
         $rates = $rateService->getApartmentRates($this->apartmentId);
         // building inventory array
         $inventory = array();
         foreach ($rates as $rate) {
             $rateID = $rate->getID();
             $rateAvailability = $rateService->getRateAvailabilityForMonth($rateID, $year, $month);
             foreach ($rateAvailability as $singleDayAvailability) {
                 $inventory[$rateID][$singleDayAvailability->getDate()] = ["availability" => $singleDayAvailability->getAvailability(), "price" => $singleDayAvailability->getPrice(), "isLockPrice" => $singleDayAvailability->getIsLockPrice()];
             }
         }
         $detailsDao = $this->getServiceLocator()->get('dao_apartment_details');
         $apartmentDetails = $detailsDao->fetchOne(['apartment_id' => $this->apartmentId], ['sync_cubilis']);
         $isConnected = $apartmentDetails->getSync_cubilis();
         $urlToggleAvailability = $this->url()->fromRoute('apartment/calendar/toggle-availability', ['apartment_id' => $this->apartmentId, 'year' => date('Y'), 'month' => date('m')]);
         $urlUpdatePrices = $this->url()->fromRoute('apartment/calendar/update-prices', ['apartment_id' => $this->apartmentId, 'year' => date('Y'), 'month' => date('m')]);
         $date = new \DateTime();
         $date->setDate($year, $month, 1);
         $monthStart = $date->format('Y-m-d');
         if ($monthStart < date('Y-m-d', strtotime('-1 days'))) {
             $monthStart = date('Y-m-d', strtotime('-1 days'));
         }
         $date->setDate($year, $month, $givenMonthDaysCount);
         $monthEnd = $date->format('Y-m-d');
         return new ViewModel(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'year' => $year, 'month' => $month, 'givenMonthName' => $givenMonthName, 'givenMonthDaysCount' => $givenMonthDaysCount, 'dayOfWeek' => $dayOfWeek, 'rates' => $rates, 'inventory' => $inventory, 'urlToggleAvailability' => $urlToggleAvailability, 'urlUpdatePrices' => $urlUpdatePrices, 'roleManager' => $roleManager, 'monthStart' => $monthStart, 'monthEnd' => $monthEnd, 'isConnected' => $isConnected]);
     } else {
         return $this->redirect()->toRoute('apartment/calendar', ["year" => date('Y'), "month" => date('m')], [], true);
     }
 }
 /**
  * The calendar component.
  *
  */
 public function calendar()
 {
     // let the loops begin! ... (dependend on the settings for the calendar view)
     for ($i = 0; $i < $this->callen; $i++) {
         // was the month before or after new year's eve?
         if ($this->month - $i >= 1 && $this->month - $i <= 12) {
             $n = $this->month - $i;
             $y = $this->year;
         } else {
             if ($this->month - $i <= 0) {
                 $n = $this->month + 12 - $i;
                 $y = $this->year - 1;
             }
             if ($this->month - $i >= 13) {
                 $n = $this->month - 12 - $i;
                 $y = $this->year + 1;
             }
         }
         $events = array();
         $days = array();
         $start = (int) date("w", strtotime("{$y}-{$n}-01"));
         $start = $start == 0 ? -5 : $start * -1 + 2;
         $stop = cal_days_in_month(CAL_GREGORIAN, $n, $y);
         // appending all events first, by looping the whole query
         foreach ($this->query as $rs) {
             // append events from the current month only
             if (date("n", $rs['timestamp']) == $n && date("Y", $rs['timestamp']) == $y) {
                 /*
                 make sure that days with more than one event
                 point to dates, and days with single events to 
                 ids.
                 */
                 $j = date("j", $rs['timestamp']);
                 if (!key_exists($j, $events)) {
                     $events[$j] = array('key' => $j, 'class' => 'event', 'url' => $rs['id'], 'title' => $rs['title']);
                 } else {
                     $events[$j]['class'] = 'events';
                     $events[$j]['url'] = $this->calLink . date("Y/n/j", $rs['timestamp']);
                     $events[$j]['count'] = isset($events[$j]['count']) ? $events[$j]['count']++ : 2;
                 }
             }
         }
         // creating the collection containing the whole month
         for ($j = $start; $j <= $stop; $j++) {
             if (key_exists($j, $events)) {
                 $days[$j] = $events[$j];
             } else {
                 $days[$j] = $j <= 0 ? array('key' => $j, 'class' => 'blank') : array('key' => $j, 'class' => date('Ynj') == $y . $n . $j ? 'today' : 'normal');
             }
         }
         // split the array into weeks
         $this->arr['calendar'][] = array('name' => getMonthName($n) . ' ' . $y, array_chunk($days, 7, true));
     }
     // reverse calendar if wanted
     if ($this->revcal) {
         $this->arr['calendar'] = array_reverse($this->arr['calendar']);
     }
 }
Example #28
0
 public function tabelAction(Request $request)
 {
     $context = ['time' => date('Y-m-d H:i:s'), 'function' => __METHOD__];
     try {
         $user = $this->getUser();
         if (!$user) {
             throw new AuthenticationException('User was not founded');
         }
         $context['user_id'] = $this->getUser()->getId();
         $info = DBBoss::getInstance()->getUserInfo($user);
         $parameters = ['month' => $request->get('month'), 'year' => $request->get('year'), 'school_id' => $info[0]['SCL_ID'], 'class_id' => $request->get('class_id')];
         $days_in_month = cal_days_in_month(CAL_GREGORIAN, $parameters['month'], $parameters['year']);
         $pupils = DBBoss::getInstance()->getAllPupil($parameters);
         $parameters['date_to'] = $parameters['year'] . '-' . ($parameters['month'] + 1) . '-01';
         $parameters['date_from'] = $parameters['year'] . '-' . $parameters['month'] . '-01';
         foreach ($pupils as $pupil) {
             $user_total = 0;
             $food_user_date = [];
             $parameters['pupil_id'] = $pupil['usr_id'];
             $food_date_info = DBBoss::getInstance()->getFoodCountForBjtPupil($parameters);
             foreach ($food_date_info as $key => $date) {
                 $food_user_date[$date['date']] = $date['cnt'];
             }
             for ($day = 1; $day <= $days_in_month; $day++) {
                 $date = $parameters['year'] . '-' . $parameters['month'] . '-' . ($day < 10 ? '0' . $day : $day);
                 if (array_key_exists($date, $food_user_date)) {
                     $result[$pupil['usr_id']][$day] = $food_user_date[$date];
                     $user_total += $food_user_date[$date];
                 } else {
                     $result[$pupil['usr_id']][$day] = 0;
                 }
             }
             $result[$pupil['usr_id']][$day] = $user_total;
         }
         $itog_total = 0;
         $parameters['date_to'] = $parameters['year'] . '-' . ($parameters['month'] + 1) . '-01';
         $parameters['date_from'] = $parameters['year'] . '-' . $parameters['month'] . '-01';
         $itog_result = DBBoss::getInstance()->getFoodBjtCountItog($parameters);
         $itog_result_date = [];
         foreach ($itog_result as $key => $date) {
             $itog_result_date[$date['date']] = $date['cnt'];
         }
         for ($day = 1; $day <= $days_in_month; $day++) {
             $date = $parameters['year'] . '-' . $parameters['month'] . '-' . ($day < 10 ? '0' . $day : $day);
             if (array_key_exists($date, $itog_result_date)) {
                 $itog[$day] = $itog_result_date[$date];
                 $itog_total += $itog[$day];
             } else {
                 $itog[$day] = 0;
             }
         }
         $itog[$day] = $itog_total;
         return $this->render('CabinetBundle:Boss/rep_tabel_cat:rep_tabel_cat_report.html.twig', ['result' => isset($result) ? $result : [], 'pupils' => $pupils, 'days' => $days_in_month, 'total' => isset($itog) ? $itog : []]);
     } catch (Exception $e) {
         $this->get('logger')->error($e->getMessage(), $context);
         return new Response('Ошибка. Обратитесь к администратору');
     }
 }
Example #29
0
 public function actionProceed()
 {
     $realize = '';
     $realizeSum = 0;
     $curRealize = '';
     $curRealizeSum = 0;
     $curProceed = '';
     $curAverSum = 0;
     $count = 0;
     $summ = '';
     $summP = '';
     $dateList = '';
     $averSum = 0;
     $averProcSum = 0;
     $monthRus = array(1 => 'Янв', 2 => 'Фев', 3 => 'Мар', 4 => 'Апр', 5 => 'Май', 6 => 'Июн', 7 => 'Июл', 8 => 'Авг', 9 => 'Сен', 10 => 'Окт', 11 => 'Ноя', 12 => 'Дек');
     $temp = explode('-', $_POST['dates']);
     //$_POST['month'];
     $month = $temp[1];
     $year = $temp[0];
     $number = cal_days_in_month(CAL_GREGORIAN, $month, $year);
     for ($i = 1; $i <= $number; $i++) {
         $model = Yii::app()->db->createCommand()->select('procProceeds,proceeds')->from('mBalance')->where('b_date = :dates', array(':dates' => $year . "-" . $month . "-" . $i))->queryRow();
         $dateList .= "'" . $i . "-" . $monthRus[$month] . "',";
         if (!empty($model)) {
             $summP .= $model["procProceeds"] . ",";
             $summ .= $model["proceeds"] . ",";
             $averSum = $averSum + $model["proceeds"];
             $averProcSum = $averProcSum + $model["procProceeds"];
         } else {
             $summP .= 0 . ",";
             $summ .= 0 . ",";
             $averSum = $averSum + 0;
             $averProcSum = $averProcSum + 0;
         }
         $model2 = Yii::app()->db->createCommand()->select('proceed,parish')->from('mInfo')->where('info_date = :dates', array(':dates' => $year . "-" . $month . "-" . $i))->queryRow();
         if (!empty($model2)) {
             $curProceed .= $model2['proceed'] . ",";
             $curAverSum = $curAverSum + $model2['proceed'];
             $curRealize .= $model2['parish'] . ",";
             $curRealizeSum = $curRealizeSum + $model2['parish'];
         } else {
             $curProceed .= 0 . ",";
             $curAverSum = $curAverSum + 0;
             $curRealize .= 0 . ",";
             $curRealizeSum = $curRealizeSum + 0;
         }
         $model3 = Yii::app()->db->createCommand()->select('fa.realize_date,sum(re.price*re.count) as Summ')->from('faktura fa')->join('realize re', 're.faktura_id = fa.faktura_id')->where('date(fa.realize_date) = :dates', array(':dates' => $year . "-" . $month . "-" . $i))->group('date(fa.realize_date)')->queryRow();
         if (!empty($model3)) {
             $realize .= number_format($model3['Summ'], 0, ',', '') . ",";
             $realizeSum = $realizeSum + $model3['Summ'];
         } else {
             $realize .= 0 . ",";
             $realizeSum = $realizeSum + 0;
         }
         $count++;
     }
     $this->renderPartial('proceed', array('dateList' => $dateList, 'averSum' => $averSum, 'averProcSum' => $averProcSum, 'count' => $count, 'summP' => $summP, 'summ' => $summ, 'curProceed' => $curProceed, 'curAverSum' => $curAverSum, 'realize' => $realize, 'curRealize' => $curRealize, 'realizeSum' => $realizeSum, 'curRealizeSum' => $curRealizeSum));
 }
 function _createEditCalendar($monthNum, $year, $selectedDates)
 {
     global $TABLE_PREFIX;
     $html = '';
     // display header
     static $monthNames = array('null', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
     $monthName = $monthNames[$monthNum];
     $html .= "<table border='1' cellspacing='0' cellpadding='2' style='float: left; margin: 10px'>\n";
     $html .= "<tr><th colspan='7' class='mo'>{$monthName} {$year}</th></tr>\n";
     $html .= "<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>\n";
     $html .= "\n<tr>\n";
     // display leading blank days
     $dayOfWeekCount = 1;
     $firstDayTime = mktime(0, 0, 0, $monthNum, 1, $year);
     $firstDayOffset = date('w', $firstDayTime);
     for ($i = 1; $i <= $firstDayOffset; $i++) {
         $html .= "<td><span class='dte0'>&nbsp;</span></td>\n";
         $dayOfWeekCount++;
     }
     // print days of month
     $rows = 1;
     $daysInMonth = cal_days_in_month(0, $monthNum, $year);
     foreach (range(1, $daysInMonth) as $dayNum) {
         $dateString = sprintf("%04d%02d%02d", $year, $monthNum, $dayNum);
         $checkedAttr = @$selectedDates[$dateString] ? 'checked="checked"' : '';
         $html .= "<td>";
         $html .= "<label for='{$this->name}:{$dateString}'>&nbsp;{$dayNum}&nbsp;</label>";
         $html .= "<input type='hidden'   name='{$this->name}:{$dateString}' value='0' />";
         $html .= "<input type='checkbox' name='{$this->name}:{$dateString}' id='{$this->name}:{$dateString}' value='1' {$checkedAttr} style='margin: 0px' />";
         $html .= "</td>\n";
         if ($dayOfWeekCount == 7) {
             $html .= "</tr>\n\n<tr>\n";
             $dayOfWeekCount = 0;
             $rows++;
         }
         $dayOfWeekCount++;
     }
     // display trailing blank days
     while ($dayOfWeekCount <= 7) {
         $html .= "<td><span class='dte0'>&nbsp;</span></td>\n";
         $dayOfWeekCount++;
     }
     $html .= "</tr>\n";
     // display 6 rows (even if last row is all blank)
     while ($rows < 6) {
         $html .= "<tr>\n";
         foreach (range(1, 7) as $n) {
             $html .= "<td><span class='dte0'>&nbsp;</span></td>\n";
         }
         $html .= "</tr>\n";
         $rows++;
     }
     // display footer
     $html .= "</table>\n\n";
     //
     return $html;
 }