Пример #1
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $colonie = $builder->getData();
     $lastDate = $colonie->getDateColonie();
     if (!$colonie->getVisites()->isEmpty()) {
         $date = $colonie->getVisites()->last()->getDate();
         if ($lastDate < $date) {
             $lastDate = $date;
         }
     }
     if (!$colonie->getTranshumances()->isEmpty()) {
         $date = $colonie->getTranshumances()->last()->getDate();
         if ($lastDate < $date) {
             $lastDate = $date;
         }
     }
     if (!$colonie->getRecoltes()->isEmpty()) {
         $date = $colonie->getRecoltes()->last()->getDate();
         if ($lastDate < $date) {
             $lastDate = $date;
         }
     }
     if (!$colonie->getRemerages()->isEmpty()) {
         $date = $colonie->getRemerages()->last()->getDate();
         if ($lastDate < $date) {
             $lastDate = $date;
         }
     }
     $startDate = date_add($lastDate, date_interval_create_from_date_string("1 days"));
     $startDateFormat = date_format($startDate, "Y-m-d");
     $builder->add('dateMort', 'collot_datetime', array('pickerOptions' => array('format' => 'dd/mm/yyyy', 'autoclose' => true, 'startDate' => (string) $startDateFormat, 'endDate' => date("Y-m-d"), 'startView' => 'month', 'minView' => 'month', 'maxView' => 'month', 'todayBtn' => false, 'todayHighlight' => true, 'keyboardNavigation' => true, 'language' => 'fr', 'forceParse' => true, 'pickerReferer ' => 'default', 'pickerPosition' => 'bottom-right', 'viewSelect' => 'month', 'initialDate' => date("Y-m-d")), 'constraints' => new CheckDateMort($colonie), 'read_only' => true, 'attr' => array('input_group' => array('prepend' => '.icon-calendar'))))->add('causes', 'entity', array('class' => 'KGBeekeepingManagementBundle:Cause', 'choice_label' => 'libelle', 'multiple' => true, 'required' => false))->add('autreCause', 'text', array('required' => false, 'constraints' => new CheckCauseMort()));
 }
Пример #2
0
 public function indexChef()
 {
     $filiere = Session::get('user')->filieres[0];
     $etudiants_count = Filiere::nbreEtudiantByFiliere($filiere->id);
     $enseignants_count = Enseignant::count();
     $etudiants = Etudiant::etudiants_plus_3_absences();
     $promotions = $filiere->promos;
     $promos_count = count($promotions);
     $stats_cours = array();
     $today = Carbon::now();
     $liste = null;
     $j = 0;
     $absences_count = 0;
     if ($promos_count > 0) {
         foreach ($promotions as $promotion) {
             $absences_count = $absences_count + Filiere::nbreAbsencesByPromo($promotion->id);
         }
     }
     $stats_cours = array();
     $today = Carbon::now();
     for ($i = 0; $i < 10; $i++) {
         $nb = Absence::whereDate('created_at', '=', date("Y-m-d", strtotime($today)))->count();
         date_add($today, date_interval_create_from_date_string('-1 days'));
         array_push($stats_cours, $nb);
     }
     return View('app/dashboardChef', ['etudiants_count' => $etudiants_count, 'enseignants_count' => $enseignants_count, 'absences_count' => $absences_count, 'promos_count' => $promos_count, 'etudiants' => $etudiants, 'statistics' => $liste[0], 'promotions' => $promotions, 'filiere' => $filiere, 'statistics' => $stats_cours]);
 }
Пример #3
0
 public function depreciated_date()
 {
     $date = date_create($this->purchase_date);
     date_add($date, date_interval_create_from_date_string($this->get_depreciation()->months . ' months'));
     return $date;
     //date_format($date, 'Y-m-d'); //don't bake-in format, for internationalization
 }
function getDates($dayofmonth, $months = 0)
{
    $dayofmonth = zeropad($dayofmonth);
    $year = date('Y');
    $month = date('m');
    if (date('d') >= $dayofmonth) {
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_add($date_end, date_interval_create_from_date_string('1 月'));
    } else {
        // Billing day will happen this month, therefore started last month
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_sub($date_start, date_interval_create_from_date_string('1 月'));
    }
    if ($months > 0) {
        date_sub($date_start, date_interval_create_from_date_string($months . ' 月'));
        date_sub($date_end, date_interval_create_from_date_string($months . ' 月'));
    }
    #  date_sub($date_start, date_interval_create_from_date_string('1 月'));
    date_sub($date_end, date_interval_create_from_date_string('1 天'));
    $date_from = date_format($date_start, 'Ymd') . "000000";
    $date_to = date_format($date_end, 'Ymd') . "235959";
    date_sub($date_start, date_interval_create_from_date_string('1 月'));
    date_sub($date_end, date_interval_create_from_date_string('1 月'));
    $last_from = date_format($date_start, 'Ymd') . "000000";
    $last_to = date_format($date_end, 'Ymd') . "235959";
    $return['0'] = $date_from;
    $return['1'] = $date_to;
    $return['2'] = $last_from;
    $return['3'] = $last_to;
    return $return;
}
Пример #5
0
function get_comic($comic, $date) {
  global $sql;

  $res=$sql->query("select gfx, strftime('%s', 'now')-strftime('%s', timestamp) as last from comics_date where comic='$comic' and date='$date'");
  if($elem=$sql->fetch_assoc($res)) {
    if($elem['gfx'])
      return $elem["gfx"];
    elseif(!date_is_after($date, date_add(date_get_today(), -60))) {
      return null;
    }
    elseif((!date_is_after($date, date_add(date_get_today(), -2)))&&($elem['last']>24*60*60))
      return null;
    elseif($elem['last']>60)
      return null;
  }

  $fun="{$comic}_check";
  $gfx=$fun($date);
  if($gfx)
    $gfx_sql="\"$gfx\"";
  else
    $gfx_sql="null";

  $sql->query("insert or replace into comics_date values ('$comic', '$date', $gfx_sql, null, datetime('now'))");

  return $gfx;
}
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validation = Validator::make(Input::all(), ['duration' => 'required | integer', 'pace' => 'required | integer', 'dog_friendliness' => 'required | integer', 'comments' => 'required']);
     if ($validation->fails()) {
         return Redirect::back()->withInput()->withErrors($validation->messages());
     }
     $walk = new Walk();
     $duration = Input::get('duration');
     $dog_friendliness = Input::get('dog_friendliness');
     $pace = Input::get('pace');
     $comments = Input::get('comments');
     $start = new DateTime();
     $start->setTimezone(new DateTimeZone('America/New_York'));
     $dateInterval = new DateInterval('PT' . $duration . 'M');
     $finish = date_add($start, $dateInterval);
     $walk->start = $start;
     $walk->finish = $finish;
     $walk->host_id = Auth::user()->id;
     $walk->dog_friendliness = $dog_friendliness;
     $walk->pace = $pace;
     $walk->comments = $comments;
     if ($walk->save()) {
         return Redirect::route('walk.index');
     }
 }
Пример #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var EntityManager em */
     $em = $this->getContainer()->get('doctrine')->getManager();
     $users = $em->getRepository('ESNUserBundle:User')->findBy(array("esner" => 1));
     $concerned_users = new ArrayCollection();
     /** @var User $user */
     foreach ($users as $user) {
         /** @var EsnerFollow $follow */
         $follow = $user->getFollow();
         if ($follow) {
             $trial = $follow->getTrialstarted();
             $end_trial = $trial;
             date_add($trial, date_interval_create_from_date_string('21 days'));
             $now = new \DateTime();
             if ($end_trial->format('d/m/Y') == $now->format('d/m/Y')) {
                 $concerned_users->add($user);
             }
         }
     }
     /** @var User $concerned_user */
     foreach ($concerned_users as $concerned_user) {
         $message = \Swift_Message::newInstance()->setSubject('[ESN Lille][ERP] Periode d\'essaie terminé pour ' . $concerned_user->getFullname())->setFrom($this->getContainer()->getParameter('mailer_from'))->setTo($user->getEmail())->setBody($this->getContainer()->get('templating')->render('ESNHRBundle:Emails:trial_ended.html.twig', array('user' => $concerned_user)), 'text/html');
         $this->getContainer()->get('mailer')->send($message);
     }
 }
Пример #8
0
function getSMA_sub_real($company, $from = "1900-01-01 00:00:00", $to = null, $dataorg = "json", $samplePeriod = 15, $enSignals = false, $host, $db, $user, $pass)
{
    $intervalPeriod = $samplePeriod * 1.5;
    //from date has to be adjusted for the bollinger bands
    $date = date_create($from);
    date_add($date, date_interval_create_from_date_string("-{$intervalPeriod} days"));
    $fromAdjusted = date_format($date, "Y-m-d");
    $dataOhlc = [];
    //OHLC data format [timestamp,open,high,low,close,volume]
    if ($dataorg == "highchart") {
        $dataOhlc = getOHLC($company, $fromAdjusted, $to, "array2", $host, $db, $user, $pass);
    } else {
        $dataOhlc = getOHLC($company, $fromAdjusted, $to, "array", $host, $db, $user, $pass);
    }
    //Return if $dataOhlc is null
    if ($dataOhlc == [] || $dataOhlc == 0) {
        return 0;
    }
    //Input for SMA functions should be [timestamp,close]
    $ctr = 0;
    foreach ((array) $dataOhlc as $ohlc) {
        $dbreturn[$ctr][0] = $ohlc[0];
        //timestamp
        $dbreturn[$ctr++][1] = $ohlc[4];
        //close
    }
    return $dbreturn;
}
function groupHasThirdWeekHours($groupInfo)
{
    $today = new DateTime();
    date_add($today, date_interval_create_from_date_string('14 days'));
    $nextWeek = date_format($today, "Y-m-d");
    return strcmp($groupInfo['addHrsType'], "week") == 0 && strcmp($nextWeek, $groupInfo['startDate']) > 0 && strcmp($nextWeek, $groupInfo['endDate']) < 0;
}
Пример #10
0
 public function checkValidCode($referCode)
 {
     $isEnabled = Engine_Api::_()->getApi('settings', 'core')->getSetting('user_referral_enable', 1);
     $period = Engine_Api::_()->getApi('settings', 'core')->getSetting('user_referral_trial', 0);
     $now = date("Y-m-d H:i:s");
     $invite = Engine_Api::_()->invite()->getRowCode($referCode);
     //check invite code active
     if (isset($invite) && !$invite->active) {
         return false;
     }
     if ($isEnabled && $invite) {
         //if exist code then get expire date
         if ($period == 1) {
             $type = 'day';
         } else {
             $type = 'days';
         }
         $expiration_date = date_add(date_create($invite->timestamp), date_interval_create_from_date_string($period . " " . $type));
         $nowDate = date_create($now);
         if ($period != 0) {
             if ($nowDate >= $expirationDate) {
                 return true;
             } else {
                 return false;
             }
         } else {
             //if code never expired
             return true;
         }
     } else {
         return false;
     }
 }
Пример #11
0
 private function addDaysFromNow($days)
 {
     $now = date('Y-m-d');
     $date = date_create($now);
     date_add($date, date_interval_create_from_date_string($days . ' days'));
     return date_format($date, 'Y-m-d');
 }
Пример #12
0
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $clientSettings = $session->get('client/settings');
     $slaId = $request->get('id');
     $dateFrom = $request->get('date_from');
     $dateTo = $request->get('date_to');
     $issues = $this->getRepository(Sla::class)->getIssues($slaId, $dateFrom, $dateTo);
     $dates = array();
     $succeeded = array();
     $breached = array();
     $dateTemporary = new \DateTime($dateFrom, new \DateTimeZone($clientSettings['timezone']));
     while (date_format($dateTemporary, 'Y-m-d') <= $dateTo) {
         $dates[] = date_format($dateTemporary, 'Y-m-d');
         $succeeded[end($dates)] = 0;
         $breached[end($dates)] = 0;
         date_add($dateTemporary, date_interval_create_from_date_string('1 days'));
     }
     while ($issues && ($issue = $issues->fetch_array(MYSQLI_ASSOC))) {
         if ($issue['sla_value'] >= 0) {
             $succeeded[substr($issue['stopped_date'], 0, 10)]++;
         } else {
             $breached[substr($issue['stopped_date'], 0, 10)]++;
         }
     }
     $data = array('dates' => $dates, 'succeeded' => $succeeded, 'breached' => $breached);
     return new JsonResponse($data);
 }
Пример #13
0
 public function historico_acceso($data, $limit = -1, $offset = -1)
 {
     $fecha = date_create(date('Y-m-j'));
     date_add($fecha, date_interval_create_from_date_string('-1 month'));
     $data['fecha_inicial'] = date_format($fecha, 'm');
     $data['fecha_final'] = $data['fecha_final'] = date('m');
     $this->db->select("AES_DECRYPT(h.email,'{$this->key_hash}') AS email", FALSE);
     $this->db->select('p.id_perfil, p.perfil, p.operacion');
     $this->db->select('u.nombre,u.apellidos');
     $this->db->select('h.ip_address, h.user_agent, h.id_usuario');
     $this->db->select("( CASE WHEN h.fecha = 0 THEN '' ELSE DATE_FORMAT(FROM_UNIXTIME(h.fecha),'%d-%m-%Y %H:%i:%s') END ) AS fecha", FALSE);
     $this->db->from($this->historico_acceso . ' As h');
     $this->db->join($this->usuarios . ' As u', 'u.id = h.id_usuario', 'LEFT');
     $this->db->join($this->perfiles . ' As p', 'u.id_perfil = p.id_perfil', 'LEFT');
     //gmt_to_local( $timestamp, 'UM1', TRUE) )
     if ($data['fecha_inicial'] and $data['fecha_final']) {
         $this->db->where("( CASE WHEN h.fecha = 0 THEN '' ELSE DATE_FORMAT(FROM_UNIXTIME(h.fecha),'%m') END ) = ", $data['fecha_inicial']);
         $this->db->or_where("( CASE WHEN h.fecha = 0 THEN '' ELSE DATE_FORMAT(FROM_UNIXTIME(h.fecha),'%m') END ) = ", $data['fecha_final']);
     }
     if ($limit != -1) {
         $this->db->limit($limit, $offset);
     }
     $this->db->order_by('h.fecha', 'desc');
     $login = $this->db->get();
     if ($login->num_rows() > 0) {
         return $login->result();
     } else {
         return FALSE;
     }
     $login->free_result();
 }
Пример #14
0
function getDates($dayofmonth, $months = 0)
{
    $dayofmonth = zeropad($dayofmonth);
    $year = date('Y');
    $month = date('m');
    if (date('d') > $dayofmonth) {
        // Billing day is past, so it is next month
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_add($date_end, date_interval_create_from_date_string('1 month'));
    } else {
        // Billing day will happen this month, therefore started last month
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_sub($date_start, date_interval_create_from_date_string('1 month'));
    }
    if ($months > 0) {
        date_sub($date_start, date_interval_create_from_date_string($months . ' month'));
        date_sub($date_end, date_interval_create_from_date_string($months . ' month'));
    }
    // date_sub($date_start, date_interval_create_from_date_string('1 month'));
    date_sub($date_end, date_interval_create_from_date_string('1 day'));
    $date_from = date_format($date_start, 'Ymd') . '000000';
    $date_to = date_format($date_end, 'Ymd') . '235959';
    date_sub($date_start, date_interval_create_from_date_string('1 month'));
    date_sub($date_end, date_interval_create_from_date_string('1 month'));
    $last_from = date_format($date_start, 'Ymd') . '000000';
    $last_to = date_format($date_end, 'Ymd') . '235959';
    $return = array();
    $return['0'] = $date_from;
    $return['1'] = $date_to;
    $return['2'] = $last_from;
    $return['3'] = $last_to;
    return $return;
}
Пример #15
0
 public function notify_payment()
 {
     $this->load->model('client_model');
     $this->load->model('bill_model');
     $received_data = $this->input->post();
     $user_name = $this->session->userdata('username');
     $get_email = $this->client_model->get_email_id($user_name);
     $get_balance = $this->bill_model->get_balance($received_data["invoice"], $get_email);
     $balance = floatval($get_balance[0]['balance']) - floatval($received_data["mc_gross_1"]);
     // echo $get_balance[0]['balance']."<br/>".$received_data["mc_gross_1"]."<br/>".$balance;
     $data = array("transaction_id" => $received_data["txn_id"], "gateway" => "Paypal", 'bill_id' => $received_data["invoice"], "user_email" => $get_email, "credit" => $received_data["mc_gross_1"], "vat" => $received_data['mc_gross_2'], "balance" => $balance, "transaction_date_time" => $received_data["payment_date"]);
     $this->bill_model->insert_transaction($data);
     $partial_status = 0;
     $bill_due_date = $this->bill_model->bill_due_date($received_data["invoice"]);
     if ($balance > 0) {
         $date = date_create($bill_due_date[0]['bill_due_date']);
         date_add($date, date_interval_create_from_date_string("15 days"));
         $bill_date = date_format($date, "Y-m-d");
         $data = array("bill_due_date" => $bill_date, "bill_allow_partial" => 0, "bill_to_paid" => $bill_due_date[0]["bill_to_paid"] + $received_data["mc_gross_1"], 'bill_due_amount' => $balance, "partial_status" => 1);
         $data1 = array("status" => 1);
         $this->bill_model->update_bill($data, $received_data["invoice"]);
         $this->bill_model->update_bill_service($data1, $received_data["invoice"]);
     } else {
         $data = array("bill_to_paid" => $bill_due_date[0]["bill_to_paid"] + $received_data["mc_gross_1"], 'bill_due_amount' => $balance, "bill_status" => 1);
         $data1 = array("status" => 1);
         $this->bill_model->update_bill($data, $received_data["invoice"]);
         $this->bill_model->update_bill_service($data1, $received_data["invoice"]);
     }
     $data = array("transaction_id" => $received_data["txn_id"], "gateway" => "Paypal", 'bill_id' => $received_data["invoice"], "balance" => $balance, "credit" => $received_data["mc_gross_1"], "transaction_date_time" => $received_data["payment_date"]);
     $this->session->set_userdata($data);
     redirect('/client/view_bill_details/' . $received_data["invoice"]);
 }
Пример #16
0
 public function check_due_date($date)
 {
     echo $date;
     $query = $this->db->query('SELECT * FROM rent_details')->result_array();
     //exit();
     foreach ($query as $key) {
         $due_date = $key['rent_due_date'];
         $rent = $key['rent'];
         $id = $key['id'];
         $rent_balance = $key['rent_balance'];
         $new_rent_balance = $rent_balance + $rent;
         $new_date = date_create($due_date);
         date_add($new_date, date_interval_create_from_date_string("30 days"));
         $new_rent_due_date = date_format($new_date, "Y-m-d");
         echo $new_rent_due_date;
         $date1 = date_create($date);
         $date2 = date_create($due_date);
         $diff = date_diff($date1, $date2);
         $dif = $diff->format("%a");
         if ($dif == 0) {
             if ($new_rent_balance <= 0) {
                 $this->db->query("UPDATE rent_details SET rent_due = '0' WHERE id ='" . $id . "'");
                 # code...
             } else {
                 $this->db->query("UPDATE rent_details SET rent_due = '" . $new_rent_balance . "' WHERE id ='" . $id . "'");
             }
             $this->db->query("UPDATE rent_details SET rent_balance = '" . $new_rent_balance . "' WHERE id ='" . $id . "'");
             $this->db->query("UPDATE rent_details SET rent_due_date = '" . $new_rent_due_date . "' WHERE id ='" . $id . "'");
         } else {
             //$this->db->query('UPDATE rent_details SET rent_due = '0'');
         }
     }
 }
Пример #17
0
 /**
  * @test
  */
 public function setDateTimeAllowsForMockingTheCurrentTime()
 {
     $simulatedCurrentTime = new \DateTime();
     date_add($simulatedCurrentTime, new \DateInterval('P1D'));
     $context = $this->contextFactory->create(array('currentDateTime' => $simulatedCurrentTime));
     $this->assertEquals($simulatedCurrentTime, $context->getCurrentDateTime());
 }
Пример #18
0
 public function testCreateVehicle()
 {
     $problem = $this->initWithProblem();
     $vehicle = new stdClass();
     $startlocation = new stdClass();
     $startlocation->Coordinate = new stdClass();
     $startlocation->Coordinate->Latitude = "62.254622";
     $startlocation->Coordinate->Longitude = "25.787020";
     $startlocation->Coordinate->System = "WGS84";
     $endlocation = new stdClass();
     $endlocation->Coordinate = new stdClass();
     $endlocation->Coordinate->Latitude = "62.254622";
     $endlocation->Coordinate->Longitude = "25.787020";
     $endlocation->Coordinate->System = "WGS84";
     $vehicle = new stdClass();
     $vehicle->Name = "Vehicle1";
     $vehicle->StartLocation = $startlocation;
     $vehicle->EndLocation = $endlocation;
     $vehicle->RelocationType = "None";
     $timeWindow = new stdClass();
     $now = new DateTime();
     $timeWindow->Start = $now->format('Y-m-d H:i:s');
     $end = date_add($now, date_interval_create_from_date_string('12 hours'));
     $timeWindow->End = $end->format('Y-m-d H:i:s');
     $vehicle->TimeWindows = $timeWindow;
     $vehicle->Capacities = array(array("Amount" => 100, "Name" => "Weight"));
     $resp = $this->api->navigate(getLink($problem, "create-vehicle"), $vehicle);
     $v = $this->api->navigate($resp);
     $this->assertEquals("Vehicle1", $v->Name);
     unset($api);
 }
Пример #19
0
 public function finanzas()
 {
     $user = \Auth::User();
     $now = new \DateTime();
     $lasth_month = date_add($now, date_interval_create_from_date_string("-1 months"));
     $now = new \DateTime();
     $last_last_month = date_add($now, date_interval_create_from_date_string("-2 months"));
     $now = new \DateTime();
     //\DB::select("delete from comisiones where periodo <> extract(year_month from ?) and periodo <> extract(year_month from ?) and periodo <> extract(year_month from ?)", [$now, $lasth_month, $last_last_month]);
     if (!$user->isContabilidad) {
         $distribuidores = [];
         $subdistribuidores = [];
         if ($user->isAdmin) {
             $distribuidores = \DB::table('users')->get();
             foreach ($distribuidores as $distribuidor) {
                 $subdistribuidores[$distribuidor->name] = \DB::table('subdistribuidores')->where('emailDistribuidor', $distribuidor->email)->get();
             }
         } else {
             $subdistribuidores = \DB::table('subdistribuidores')->where('emailDistribuidor', $user->email)->get();
         }
         $periodos = \DB::select("select distinct periodo from comisiones order by periodo desc");
         return view('/finanzas', array('user' => $user, 'subdistribuidores' => $subdistribuidores, 'distribuidores' => $distribuidores, 'periodos' => $periodos));
     } else {
         $distribuidores = \DB::table('users')->where('name', '<>', 'OFICINA')->get();
         foreach ($distribuidores as $distribuidor) {
             $subdistribuidores[$distribuidor->name] = \DB::table('subdistribuidores')->where('emailDistribuidor', $distribuidor->email)->get();
         }
         $periodos = \DB::select("select distinct periodo from comisiones order by periodo desc");
         return view('/finanzas', array('user' => $user, 'subdistribuidores' => $subdistribuidores, 'distribuidores' => $distribuidores, 'periodos' => $periodos));
     }
 }
Пример #20
0
 public static function store()
 {
     self::check_logged_in(array("asiakas", "tyontekija", "johtaja"));
     $params = $_POST;
     $palvelu = Palvelu::find($params['palvelu_id']);
     $aloitusaika = strtotime($params['paiva'] . ' ' . $params['kellonaika']);
     list($tunnit, $minuutit, $sekunnit) = sscanf($palvelu->kesto, '%d:%d:%d');
     $kesto = new DateInterval(sprintf('PT%dH%dM', $tunnit, $minuutit));
     $lopetusaika = date_timestamp_get(date_add(new DateTime('@' . $aloitusaika), $kesto));
     $attributes = array('asiakas_id' => $params['asiakas_id'], 'palvelu_id' => $params['palvelu_id'], 'tyontekija_id' => $params['tyontekija_id'], 'toimitila_id' => $params['toimitila_id'], 'aloitusaika' => date('Y-m-d H:i', $aloitusaika), 'lopetusaika' => date('Y-m-d H:i', $lopetusaika), 'on_peruutettu' => NULL);
     $varaus = new Varaus($attributes);
     $errors = $varaus->errors();
     // tarkistetaan resurssien ja asiakkaan saatavuus varausajalle
     if (count($errors) == 0) {
         $errors = $varaus->check_overlaps();
     }
     if (count($errors) > 0) {
         $tyontekijat = Tyontekija::all();
         $palvelut = Palvelu::all();
         $toimitilat = Toimitila::all();
         $asiakkaat = Asiakas::all();
         View::make('varaus/varaus_lisaa.html', array('errors' => $errors, 'varaus' => $varaus, 'tyontekijat' => $tyontekijat, 'palvelut' => $palvelut, 'toimitilat' => $toimitilat, 'asiakkaat' => $asiakkaat));
     } else {
         $varaus->save();
         Redirect::to('/', array('message' => 'Varaus tallennettu.'));
     }
 }
Пример #21
0
    public function show()
    {
        //nuvarande månad
        $d = "20" . $this->year . "-" . $this->monthNr . "-01";
        $date = date_create($d);
        //nästa månad
        $nextdate = date_add($date, date_interval_create_from_date_string('1 month'));
        $next = "y=" . date_format($nextdate, "y") . "&amp;m=" . date_format($nextdate, "n");
        //föregående månad
        $prevdate = date_sub($date, date_interval_create_from_date_string('2 months'));
        $prev = "y=" . date_format($prevdate, "y") . "&amp;m=" . date_format($prevdate, "n");
        $html = <<<EOT
     <header>
     <a class="left navsquare" href="?p=calendar&amp;{$prev}">&#10094;</a>
     <a class="right navsquare" href="?p=calendar&amp;{$next}">&#10095;</a>
     <h2 class="strokeme">{$this->month} 20{$this->year}</h2>
     <img class="header" src="img/calendar/{$this->getMonthImage()}" 
     alt="image of the month"></header>
     

    <section>\t
     {$this->calendarTable()}
     {$this->showHollidays()}
    </section>
EOT;
        return $html;
    }
Пример #22
0
function processWalking($results, $fileRow)
{
    global $csvData;
    global $sqlDB;
    global $plat;
    //this is where I'm going to do things
    foreach ($results as $result) {
        $startDate = $result['DateBegan'];
        $endDate = $result['DateStopped'];
        $diff = date_diff($startDate, $endDate);
        $days = $diff->format("%a");
        $currentDate = $result['DateBegan'];
        $formattedDate = date_format($currentDate, 'm/d/y');
        $tempData = array();
        while ($currentDate <= $endDate) {
            $dayDate = $formattedDate . ' ' . "00:00:00";
            $endDay = $formattedDate . ' ' . "23:59:59";
            $querry = "SELECT TOP 1 RecID FROM vPhoneData1\n\t\t\t\tWHERE (TaskSetName = '1 PING' or TaskSetName =\n\t\t\t\t '3 REPORT CGI_OR_H2RL') AND LocalTimetag1 > ? and\n\t\t\t\t LocalTimetag1 < ? and cast(FORMDATA as varchar(max)) like\n\t\t\t\t '%" . $plat . "%'";
            $stmt = sqlsrv_prepare($sqlDB, $querry, array(&$dayDate, &$endDay));
            sqlsrv_execute($stmt);
            $fetched = sqlsrv_fetch_array($stmt);
            if (!empty($fetched)) {
                $formattedDate = date_format($currentDate, 'm/d/y');
                $fileRow['Survey Dt'] = $formattedDate;
                $fileRow['Completed By'] = $result['TechName'];
                $fileRow['Instrument'] = $result['Instrument'];
                $fileRow['Rate'] = $result['RateCode'];
                $fileRow['Survey Method'] = 'WALK';
                $tempData[] = $fileRow;
            }
            $currentDate = date_add($currentDate, date_interval_create_from_date_string('1 days'));
            $formattedDate = date_format($currentDate, 'm/d/y');
            $fetched = null;
        }
        if (!empty($tempData)) {
            $daycount = count($tempData);
            if ($result[6] > 0) {
                $dailyTotal = floor($result[6] / $daycount);
                $firstTotal = $dailyTotal + $result[6] % $daycount;
                $isFirst = TRUE;
            } else {
                $dailyTotal = 0;
            }
            foreach ($tempData as $tempRow) {
                if ($isFirst === TRUE) {
                    $tempRow['Quantity'] = $firstTotal;
                    $isFirst = FALSE;
                } elseif ($dailyTotal > 0) {
                    $tempRow['Quantity'] = $dailyTotal;
                } else {
                    $tempRow['Quantity'] = 0;
                }
                if ($tempRow['Quantity'] > 0) {
                    $csvData[] = $tempRow;
                }
            }
        }
    }
}
Пример #23
0
function myCompare($orderedOn)
{
    global $datex;
    $orderedOn = date_create($orderedOn);
    if (date_add($datex, date_interval_create_from_date_string("-96 hours")) >= $orderedOn) {
        return "ThisExpired";
    }
}
Пример #24
0
 public function getLRLastNoticeDate($lrCreated)
 {
     $lastContactDate = clone $lrCreated;
     date_add($lastContactDate, date_interval_create_from_date_string('5 days'));
     $weekendDays = Utils::countWeekendDays($lrCreated->getTimeStamp(), $lastContactDate->getTimeStamp());
     date_add($lastContactDate, date_interval_create_from_date_string($weekendDays . ' days'));
     return $lastContactDate->format('Y-m-d');
 }
Пример #25
0
 /**
  * @test
  */
 public function setDateTimeAllowsForMockingTheCurrentTime()
 {
     $simulatedCurrentTime = new \DateTime();
     date_add($simulatedCurrentTime, new \DateInterval('P1D'));
     $contentContext = new \TYPO3\TYPO3\Domain\Service\ContentContext('live');
     $contentContext->setCurrentDateTime($simulatedCurrentTime);
     $this->assertEquals($simulatedCurrentTime, $contentContext->getCurrentDateTime());
 }
Пример #26
0
function createTimeWindowWithDuration($duration)
{
    $timeWindow = new stdClass();
    $now = new DateTime();
    $timeWindow->Start = $now->format('Y-m-d H:i:s');
    $end = date_add($now, date_interval_create_from_date_string($duration . ' hours'));
    $timeWindow->End = $end->format('Y-m-d H:i:s');
    return $timeWindow;
}
 /**
  * Выборка операций за период
  */
 public function testFillForPeriod()
 {
     $dateStart = new DateTime(date('Y-m-01'));
     $dateEnd = date_add(clone $dateStart, new DateInterval('P1M'));
     $op = $this->helper->makeOperation();
     $operationCollection = new OperationCollection($op->getUser());
     $operationCollection->setPeriodStartDate($dateStart)->setPeriodEndDate($dateEnd)->fill();
     $this->assertNotEquals(0, count($operationCollection->getOperations()));
 }
Пример #28
0
 /**
  * Time constructor.
  */
 public function __construct()
 {
     $this->currentDateTime = date("Y-m-d h:i:s");
     $this->currentDate = date("Y-m-d");
     $this->currentTime = date("h:i:s");
     $date = date_create($this->currentDate);
     date_add($date, date_interval_create_from_date_string('6 days'));
     $this->accessTokenExpirationDate = date_format($date, 'Y-m-d') . ' ' . $this->currentTime;
 }
Пример #29
0
 public function addHoliday($date_from, $date_to = '', $calendar_id)
 {
     global $wpdb;
     global $blog_id;
     $blog_prefix = $blog_id . "_";
     if ($blog_id == 1) {
         $blog_prefix = "";
     }
     if ($date_to == '') {
         //check if this day already exists
         $numrows = $wpdb->query($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_holidays WHERE holiday_date =%s AND calendar_id= %d", $date_from, $calendar_id));
         if ($numrows > 0) {
             return 0;
         } else {
             $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->base_prefix . $blog_prefix . "booking_holidays (holiday_date,calendar_id) VALUES(%s,%d)", $date_from, $calendar_id));
             $lastId = $wpdb->insert_id;
             //check if there are reservation for that date
             $checkQry = $wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_reservation r INNER JOIN " . $wpdb->base_prefix . $blog_prefix . "booking_slots s ON s.slot_id = r.slot_id WHERE s.slot_date = %s AND r.calendar_id = %d", $date_from, $calendar_id);
             $checkRows = $wpdb->query($checkQry);
             if ($checkRows > 0) {
                 $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->base_prefix . $blog_prefix . "booking_slots SET slot_active = %d WHERE slot_date=%s AND calendar_id = %d", 0, $date_from, $calendar_id));
             } else {
                 $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->base_prefix . $blog_prefix . "booking_slots WHERE slot_date = %s AND calendar_id= %d", $date_from, $calendar_id));
             }
             return $lastId;
         }
     } else {
         $arrNewIds = array();
         $datefromnum = str_replace("-", "", $date_from);
         $datetonum = str_replace("-", "", $date_to);
         $date = date_create($date_from);
         while ($datefromnum <= $datetonum) {
             $dateformat = date_format($date, 'Y-m-d');
             //check if this day already exists
             $holidayCheck = $wpdb->query($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_holidays WHERE holiday_date =%s AND calendar_id= %d", $dateformat, $calendar_id));
             if ($holidayCheck == 0) {
                 $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->base_prefix . $blog_prefix . "booking_holidays (holiday_date,calendar_id) VALUES(%s,%d)", $dateformat, $calendar_id));
                 array_push($arrNewIds, $wpdb->insert_id);
                 //check if there are reservation for that date
                 $check = $wpdb->query($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_reservation r INNER JOIN " . $wpdb->base_prefix . $blog_prefix . "booking_slots s ON s.slot_id = r.slot_id WHERE s.slot_date = %s AND r.calendar_id = %d", $dateformat, $calendar_id));
                 if ($check > 0) {
                     $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->base_prefix . $blog_prefix . "booking_slots SET slot_active = %d WHERE slot_date=%s AND calendar_id = %d", 0, $dateformat, $calendar_id));
                 } else {
                     $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->base_prefix . $blog_prefix . "booking_slots WHERE slot_date = %s AND calendar_id=%d", $dateformat, $calendar_id));
                 }
             }
             if (function_exists("date_add")) {
                 date_add($date, date_interval_create_from_date_string('1 days'));
             } else {
                 date_modify($date, '+1 day');
             }
             //date_modify($date, '+1 day');
             $datefromnum = date_format($date, 'Ymd');
         }
         return $arrNewIds;
     }
 }
Пример #30
0
function getMACD($company, $from = "1900-01-01 00:00:00", $to = null, $dataorg = "json", $host, $db, $user, $pass)
{
    $macd = [];
    $intervalPeriod = 55;
    //from date has to be adjusted for the bollinger bands
    $date = date_create($from);
    date_add($date, date_interval_create_from_date_string("-{$intervalPeriod} days"));
    $fromAdjusted = date_format($date, "Y-m-d");
    $dataOhlc = [];
    //OHLC data format [timestamp,open,high,low,close,volume]
    if ($dataorg == "highchart") {
        $dataOhlc = getOHLC($company, $fromAdjusted, $to, "array2", $host, $db, $user, $pass);
    } else {
        $dataOhlc = getOHLC($company, $fromAdjusted, $to, "array", $host, $db, $user, $pass);
    }
    //Return if $dataOhlc is null
    if ($dataOhlc == [] || $dataOhlc == 0) {
        return 0;
    }
    //Input for SMA functions should be [timestamp,close]
    $ctr = 0;
    foreach ($dataOhlc as $ohlc) {
        if ($dataorg == "json") {
            $dbreturn[$ctr][0] = $ohlc[0];
            //timestamp
            $dbreturn[$ctr][1] = $ohlc[4];
            //close
        } elseif ($dataorg == "highchart") {
            $dbreturn[$ctr][0] = $ohlc[0];
            //timestamp
            $dbreturn[$ctr][1] = $ohlc[4];
            //close
        } elseif ($dataorg == "array") {
            //TODO: create code for organizing an array data output
        } else {
            $dbreturn[$ctr][0] = $ohlc[0];
            //timestamp
            $dbreturn[$ctr][1] = $ohlc[4];
            //close
        }
        $ctr++;
    }
    if ($dataorg == "json") {
        //echo json_encode($dbreturn);
        $macd = codesword_macd($dbreturn);
        //echo json_encode($ema);
    } elseif ($dataorg == "highchart") {
        $macd = codesword_macd($dbreturn);
    } elseif ($dataorg == "array") {
        //TODO: create code for organizing an array data output
    } else {
        //json
        $macd = codesword_macd($dbreturn);
    }
    echo json_encode($macd);
}