示例#1
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @return Holiday[]
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(HolidayPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(HolidayPeer::DATABASE_NAME);
         $criteria->add(HolidayPeer::ID, $pks, Criteria::IN);
         $objs = HolidayPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
示例#2
0
 /**
  * Implementation for 'DELETE' method for Rest API
  *
  * @param  mixed $hldUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function delete($hldUid)
 {
     $conn = Propel::getConnection(HolidayPeer::DATABASE_NAME);
     try {
         $conn->begin();
         $obj = HolidayPeer::retrieveByPK($hldUid);
         if (!is_object($obj)) {
             throw new RestException(412, G::LoadTranslation('ID_RECORD_DOES_NOT_EXIST'));
         }
         $obj->delete();
         $conn->commit();
     } catch (Exception $e) {
         $conn->rollback();
         throw new RestException(412, $e->getMessage());
     }
 }
示例#3
0
 /**
  * Configuration functions
  *
  * @param string $UsrUid
  * @param string $ProUid
  * @param string $TasUid
  * @return void
  */
 public function prepareInformation($UsrUid = null, $ProUid = null, $TasUid = null)
 {
     // setup calendarDays according the task
     if (isset($TasUid)) {
         $task = TaskPeer::retrieveByPK($TasUid);
         if (!is_null($task)) {
             $this->calendarDays = $task->getTasTypeDay() == 2;
         }
     }
     //get an array with all holidays.
     $aoHolidays = HolidayPeer::doSelect(new Criteria());
     $holidays = array();
     foreach ($aoHolidays as $holiday) {
         $holidays[] = strtotime($holiday->getHldDate());
     }
     // by default the weekdays are from monday to friday
     $this->weekends = array(0, 6);
     $this->holidays = $holidays;
     return;
 }
示例#4
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's BasePeer::TYPE_PHPNAME
  *
  * @param array  $arr     An array to populate the object from.
  * @param string $keyType The type of keys the array uses.
  * @return void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = HolidayPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setAccountId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setDate($arr[$keys[3]]);
     }
 }
示例#5
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = HolidayPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setHldUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setHldDate($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setHldDescription($arr[$keys[2]]);
     }
 }
    ?>
                <?php 
    echo __("Disabled");
    ?>
                <?php 
    if ($form->getDefault($name)) {
        ?>
                  <script>disableDay(<?php 
        echo $day;
        ?>
)</script>
                <?php 
    }
    ?>
                <?php 
    if (HolidayPeer::isHoliday($day_i)) {
        ?>
                  <script>disableDayUneditable(<?php 
        echo $day;
        ?>
)</script>
                <?php 
    }
    ?>

              </td>
            <?php 
}
?>

            <?php 
示例#7
0
 /**
  * Selects a collection of HolidayDomain objects pre-filled with all related objects except Domain.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of HolidayDomain objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptDomain(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(HolidayDomainPeer::DATABASE_NAME);
     }
     HolidayDomainPeer::addSelectColumns($criteria);
     $startcol2 = HolidayDomainPeer::NUM_HYDRATE_COLUMNS;
     HolidayPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + HolidayPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(HolidayDomainPeer::HOLIDAY_ID, HolidayPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = HolidayDomainPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = HolidayDomainPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = HolidayDomainPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             HolidayDomainPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Holiday rows
         $key2 = HolidayPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = HolidayPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = HolidayPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 HolidayPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (HolidayDomain) to the collection in $obj2 (Holiday)
             $obj2->addHolidayDomain($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
示例#8
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = AccountPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related BookingType objects
         $criteria = new Criteria(BookingTypePeer::DATABASE_NAME);
         $criteria->add(BookingTypePeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += BookingTypePeer::doDelete($criteria, $con);
         // delete related ClockingType objects
         $criteria = new Criteria(ClockingTypePeer::DATABASE_NAME);
         $criteria->add(ClockingTypePeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += ClockingTypePeer::doDelete($criteria, $con);
         // delete related Domain objects
         $criteria = new Criteria(DomainPeer::DATABASE_NAME);
         $criteria->add(DomainPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += DomainPeer::doDelete($criteria, $con);
         // delete related Holiday objects
         $criteria = new Criteria(HolidayPeer::DATABASE_NAME);
         $criteria->add(HolidayPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += HolidayPeer::doDelete($criteria, $con);
         // delete related Plugin objects
         $criteria = new Criteria(PluginPeer::DATABASE_NAME);
         $criteria->add(PluginPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += PluginPeer::doDelete($criteria, $con);
         // delete related Property objects
         $criteria = new Criteria(PropertyPeer::DATABASE_NAME);
         $criteria->add(PropertyPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += PropertyPeer::doDelete($criteria, $con);
         // delete related User objects
         $criteria = new Criteria(UserPeer::DATABASE_NAME);
         $criteria->add(UserPeer::ACCOUNT_ID, $obj->getId());
         $affectedRows += UserPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
示例#9
0
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 Holiday A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `id`, `account_id`, `name`, `date` FROM `holiday` WHERE `id` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new Holiday();
         $obj->hydrate($row);
         HolidayPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
示例#10
0
 /**
  * Implementation for 'DELETE' method for Rest API
  *
  * @param  mixed $hldUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function delete($hldUid)
 {
     $conn = Propel::getConnection(HolidayPeer::DATABASE_NAME);
     try {
         $conn->begin();
         $obj = HolidayPeer::retrieveByPK($hldUid);
         if (!is_object($obj)) {
             throw new RestException(412, 'Record does not exist.');
         }
         $obj->delete();
         $conn->commit();
     } catch (Exception $e) {
         $conn->rollback();
         throw new RestException(412, $e->getMessage());
     }
 }