Example #1
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElement('RadioButton', 'type', array('label' => 'Tipo di inserimento:', 'multiOptions' => array('OFFER' => 'Offerta passaggio', 'NEED' => 'Richiesta passaggio'), 'value' => 'NEED', 'onClick' => 'rideTypeChange(this);'));
     $this->addElement('RadioButton', 'repeatable', array('label' => 'Questo inserimento è valido:', 'multiOptions' => array(0 => 'Una volta soltanto', 1 => 'Periodicamente'), 'value' => 0, 'onClick' => 'rideDateChange(this);'));
     $date = new Zend_Date();
     $this->addElement('DateTextBox', 'date', array('label' => 'Data di partenza:', 'required' => false, 'value' => $date->getIso()));
     $this->addElement('multiselect', 'weekdays', array('label' => 'Giorni di validità:', 'required' => false, 'multiOptions' => array('MONDAY' => 'Lunedì', 'TUESDAY' => 'Martedì', 'WEDNESDAY' => 'Mercoledì', 'THURSDAY' => 'Giovedì', 'FRIDAY' => 'Venerdì', 'SATURDAY' => 'Sabato', 'SUNDAY' => 'Domenica'), 'size' => 5, 'multiple' => true));
     $this->addElement('NumberSpinner', 'num_spots', array('label' => 'Posti disponibili:', 'value' => 3, 'smallDelta' => 1, 'min' => 0, 'max' => 10));
     $this->addElement('Textarea', 'purpose', array('label' => 'Motivo del viaggio:', 'required' => true, 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 255)))));
     $this->addDisplayGroup(array('type', 'repeatable', 'purpose'), 'insertion_type', array('legend' => 'Inserimento offerta'));
     $this->addDisplayGroup(array('date'), 'ride_date', array('legend' => 'Data'));
     $this->addDisplayGroup(array('weekdays'), 'ride_days', array('legend' => 'Periodo'));
     $this->addDisplayGroup(array('num_spots'), 'ride_spots', array('legend' => 'Dettagli offerta'));
     $db = Zend_Db_Table::getDefaultAdapter();
     $values = $db->fetchPairs("SELECT code, name FROM Municipality");
     //Departure town
     $this->addElement('FilteringSelect', 'dep_municipality', array('label' => 'Inserisci il comune di partenza:', 'autocomplete' => false, 'multiOptions' => $values, 'validators' => array(array('validator' => 'StringLength', 'options' => array(6, 6))), 'required' => false, 'onChange' => 'fetchTowns(this,"dep");'));
     $this->addElement('FilteringSelect', 'dep_town', array('label' => 'Inserisci la località di partenza:', 'autocomplete' => false, 'storeId' => 'depTownStore', 'storeType' => 'dojo.data.ItemFileReadStore', 'storeParams' => array('clearOnClose' => true), 'dijitParams' => array('searchAttr' => 'name')));
     //Departure time
     $this->addElement('TimeTextBox', 'dep_time', array('label' => 'Orario di partenza:', 'required' => true, 'value' => $date->getIso(), 'clickableIncrement' => 'T00:15:00', 'visibleIncrement' => 'T00:15:00'));
     $this->addDisplayGroup(array('dep_municipality', 'dep_town', 'dep_time'), 'departure', array('legend' => 'Partenza'));
     //Arrival town
     $this->addElement('FilteringSelect', 'arr_municipality', array('label' => 'Inserisci il comune di arrivo:', 'autocomplete' => false, 'multiOptions' => $values, 'validators' => array(array('validator' => 'StringLength', 'options' => array(6, 6))), 'required' => false, 'onChange' => 'fetchTowns(this,"arr");'));
     $this->addElement('FilteringSelect', 'arr_town', array('label' => 'Inserisci la località di arrivo:', 'autocomplete' => false, 'storeId' => 'arrTownStore', 'storeType' => 'dojo.data.ItemFileReadStore', 'storeParams' => array('clearOnClose' => true), 'dijitParams' => array('searchAttr' => 'name')));
     //Arrival time
     $this->addElement('TimeTextBox', 'arr_time', array('label' => 'Orario di arrivo:', 'required' => true, 'value' => $date->getIso(), 'clickableIncrement' => 'T00:15:00', 'visibleIncrement' => 'T00:15:00'));
     $this->addDisplayGroup(array('arr_municipality', 'arr_town', 'arr_time'), 'arrival', array('legend' => 'Arrivo'));
     $this->addElement('submit', 'submit', array('label' => 'Inserisci'));
 }
Example #2
0
 /**
  * indexAction lists available messages and allows to send a message to someone else
  */
 public function indexAction()
 {
     $form = $this->_getMessageForm();
     $username = $this->_getParam("username");
     if (!empty($username)) {
         $form->getElement("username")->setValue($username);
     }
     require_once APPLICATION_PATH . "/model/Message.php";
     $table = new Message();
     $messages = $table->fetchAll($table->select()->from($table, array('id', 'date', 'sender', 'subject'))->where('receiver = ?', Zend_Auth::getInstance()->getIdentity()->username));
     $this->view->messages = $messages->toArray();
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $values = $form->getValues();
         $date = new Zend_Date();
         $data['date'] = $date->getIso();
         $data['subject'] = $values['subject'];
         $data['text'] = $values['message'];
         $data['sender'] = Zend_Auth::getInstance()->getIdentity()->username;
         $data['receiver'] = $values['username'];
         $table->insert($data);
         $this->_helper->redirector('index', 'message', 'default', array('sent' => true));
     }
     $this->view->messageSent = $this->_getParam('sent');
     $this->view->messageDeleted = $this->_getParam('deleted');
     $this->view->form = $form;
 }
Example #3
0
 /**
  *
  * @param type $dateStr
  * @param type $format
  * @return type 
  */
 public static function dateLocalToCustom($dateStr, $format = '')
 {
     $date = new Zend_Date($dateStr);
     if ($format != '') {
         return $date->toString($format);
     } else {
         return $date->getIso();
     }
 }
Example #4
0
 public static function getForm()
 {
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $form = new Zend_Form();
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'editor/changesForm.phtml'))));
     $zdate = new Zend_Date();
     $e = new Zend_Dojo_Form_Element_DateTextBox('fromDate', array('label' => 'From', 'required' => true));
     $e->setAttrib('onchange', 'admin.currentManObj.refresh()');
     $form->addElement($e);
     $e = new Zend_Dojo_Form_Element_DateTextBox('toDate', array('label' => 'To', 'required' => true));
     $e->setAttrib('onchange', 'admin.currentManObj.refresh()');
     $form->addElement($e);
     //		$e = new Zend_Dojo_Form_Element_Button( 'refresh', array ('label' => 'Refresh' ) );
     //		$e->setAttrib('onchange', 'admin.currentManObj.refresh()');
     //		$form->addElement($e);
     Zend_Dojo::enableForm($form);
     $form->setDefaults(array('toDate' => $zdate->getIso(), 'fromDate' => $zdate->getIso()));
     return $form;
 }
Example #5
0
 public function evaluateAction()
 {
     $username = $this->_getParam('username');
     if (!empty($username)) {
         $form = $this->_getEvaluationForm($username);
         if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
             $values = $form->getValues();
             require_once APPLICATION_PATH . "/model/Evaluation.php";
             $table = new Evaluation();
             $date = new Zend_Date();
             $data['date'] = $date->getIso();
             $data['rating'] = $values['rating'];
             $data['motivation'] = $values['motivation'];
             $data['evaluator'] = Zend_Auth::getInstance()->getIdentity()->username;
             $data['evaluated_user'] = $username;
             $table->insert($data);
             $this->_helper->redirector('profile', 'user', 'default', array('username' => $username, 'evaluationInserted' => true));
         }
         $this->view->form = $form;
     }
 }
Example #6
0
 public static function format_iso($strDate)
 {
     $date = new Zend_Date($strDate, 'dd/MM/yyyy');
     return $date->getIso();
 }
Example #7
0
 /**
  * @ZF-7745
  *
  */
 public function testSetFirstDayOfLeapYear()
 {
     $date = new Zend_Date(2008, Zend_Date::YEAR);
     $date->setDayOfYear(1);
     $this->assertEquals('2008-01-01T00:00:00+05:00', $date->getIso());
     $date->setDayOfYear(61);
     $this->assertEquals('2008-03-01T00:00:00+05:00', $date->getIso());
     $date->setDayOfYear(62);
     $this->assertEquals('2008-03-02T00:00:00+05:00', $date->getIso());
 }
Example #8
0
 public function testToEbayValue()
 {
     $this->assertSame('1', Zend_Service_Ebay_AbstractConcrete::toEbayValue(true));
     $this->assertSame('0', Zend_Service_Ebay_AbstractConcrete::toEbayValue(false));
     require_once 'Zend/Date.php';
     $date = new Zend_Date();
     $this->assertSame($date->getIso(), Zend_Service_Ebay_AbstractConcrete::toEbayValue($date));
     $date = new DateTime();
     $this->assertSame($date->format(DateTime::ISO8601), Zend_Service_Ebay_AbstractConcrete::toEbayValue($date));
     $this->assertSame('10', Zend_Service_Ebay_AbstractConcrete::toEbayValue(10));
 }
Example #9
0
 /**
  * Test for getIso
  */
 public function testGetIso()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1010101010, null, $locale);
     $d2 = new Zend_Date(1010101010, null, $locale);
     $result = $date->getIso();
     $this->assertTrue(is_string($result));
     $this->assertSame($result, '2002-01-04T04:36:50+05:00');
 }
Example #10
0
 public function testTimezoneArray()
 {
     date_default_timezone_set('UTC');
     $date = new Zend_Date(array('year' => 2007, 'month' => 1, 'day' => 1, 'hour' => 20, 'minute' => 45, 'second' => 37, 'en_US'));
     $this->assertSame('2007-01-01T20:45:37+00:00', $date->getIso());
     date_default_timezone_set('CET');
     $date = new Zend_Date(array('year' => 2007, 'month' => 1, 'day' => 1, 'hour' => 1, 'minute' => 45, 'second' => 37, 'en_US'));
     $this->assertSame('2007-01-01T01:45:37+01:00', $date->getIso());
     $date = new Zend_Date(array('year' => 2006, 'month' => 4, 'day' => 18, 'hour' => 12, 'minute' => 3, 'second' => 10, 'de_AT'));
     $this->assertSame('2006-04-18T12:03:10+02:00', $date->getIso());
 }
 /**
  * Takes a Magento date string or Zend_Date and turns it into an
  * ISO 8601 compliant formatted string of the date.
  *
  * @param string|integer|Zend_Date $date Magento date string, Unix timestamp, or Zend_Date object
  * @return string ISO date (using Z instead of +00:00)
  */
 public function dateToIso($date)
 {
     if (is_string($date)) {
         $date = new Zend_Date($date);
     }
     if (is_int($date)) {
         $date = new Zend_Date($date, Zend_Date::TIMESTAMP);
     }
     return str_replace('+00:00', 'Z', $date->getIso());
 }
Example #12
0
 public function testFromArray()
 {
     $date = new Zend_Date(array('day' => 04, 'month' => 12, 'year' => 2006, 'hour' => 10, 'minute' => 56, 'second' => 30), 'en_US');
     $this->assertSame($date->getIso(), '2006-12-04T10:56:30+05:00');
 }
Example #13
0
 public function confirmAction()
 {
     $ride = $this->_getParam("ride");
     $user = $this->_getParam("username");
     if (!empty($ride) && !empty($user)) {
         require_once APPLICATION_PATH . "/model/UserRide.php";
         $table = new UserRide();
         $table->update(array('confirmation' => true), array($table->getAdapter()->quoteInto("ride = ?", $ride), $table->getAdapter()->quoteInto("user = ?", $user)));
         $date = new Zend_Date();
         $owner = Zend_Auth::getInstance()->getIdentity()->username;
         $mess['sender'] = $owner;
         $mess['receiver'] = $user;
         $mess['date'] = $date->getIso();
         $mess['subject'] = "Conferma partecipazione a viaggio";
         $mess['text'] = "{$owner} ha accettato la tua partecipazione al suo viaggio. Contattalo per accordarvi sui dettagli!";
         require_once APPLICATION_PATH . "/model/Message.php";
         $table = new Message();
         $table->insert($mess);
     }
 }
Example #14
0
 public function isQuestionnaireExecution($QstnId)
 {
     $date = new Zend_Date();
     $now = $date->getIso();
     $where = array('Id = ?' => $QstnId, 'OperationBeginning <= ?' => $now, 'OperationEnding >= ?' => $now);
     return DbTable_Questionnaire::getInstance()->fetchRow($where, 'OperationBeginning');
 }
Example #15
0
 /**
  * method to retreive date in ISO-8601 format
  * if date is not set retreive the current date
  * 
  * @param Zend_Date Zend date object
  * 
  * @return string Date in ISO-8601 format
  */
 public static function getDateTimeIso($date = null)
 {
     $date = new Zend_Date($date, null, Application_Model_General::getLocale(null, true));
     return $date->getIso();
 }