public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(CatalogPeer::ID, $pks, Criteria::IN); $objs = CatalogPeer::doSelect($criteria, $con); } return $objs; }
public function filter($c, $filters) { $filters_key = array_keys($filters); foreach ($filters_key as $key) { $value = $filters[$key]; if ($value == '' || $value == null) { continue; } if ($key == 'SIGN_CODE') { $c->addJoin(CatalogPeer::ID, ColItemPeer::CATALOG_ID); $column = CatalogPeer::getTableMap()->getColumn('CODE'); } elseif ($key == 'CODE') { $c->addJoin(ColLocationPeer::ID, ColItemPeer::COL_LOCATION_ID); $column = ColLocationPeer::getTableMap()->getColumn('CODE'); } elseif ($key == 'TITLE') { $c->addJoin(CatalogPeer::ID, ColItemPeer::CATALOG_ID); $column = CatalogPeer::getTableMap()->getColumn('TITLE'); } elseif ($key == 'PUBLISHER_NAME') { $c->addJoin(CatalogPeer::ID, ColItemPeer::CATALOG_ID); $c->addJoin(PublisherPeer::ID, CatalogPeer::PUBLISHER_ID); $column = PublisherPeer::getTableMap()->getColumn('NAME'); } elseif ($key == 'WRITER_NAME') { $c->addJoin(CatalogPeer::ID, ColItemPeer::CATALOG_ID); $c->addJoin(CatalogWriterPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(WriterPeer::ID, CatalogWriterPeer::WRITER_ID); $column = WriterPeer::getTableMap()->getColumn('NAME'); } elseif ($key == 'CAT_CATEGORY_ID') { $c->addJoin(CatalogPeer::ID, ColItemPeer::CATALOG_ID); $c->addJoin(CatCategoryPeer::ID, CatalogPeer::CAT_CATEGORY_ID); $column = CatCategoryPeer::getTableMap()->getColumn('ID'); } else { $column = ColItemPeer::getTableMap()->getColumn($key); } $name = $column->getFullyQualifiedName(); $creoleType = $column->getCreoleType(); if ($creoleType == CreoleTypes::TIMESTAMP) { $from = $value['from']; $to = $value['to']; if ($from != '' && $from != null) { $c->add($name, $from, Criteria::GREATER_EQUAL); } if ($to != '' && $to != null) { $c->add($name, $to, Criteria::LESS_EQUAL); } } else { if ($creoleType == CreoleTypes::INTEGER || $creoleType == CreoleTypes::BIGINT) { $c->add($name, $value, Criteria::EQUAL); } else { if ($creoleType == CreoleTypes::VARCHAR) { $c->add($name, "%{$value}%", Criteria::LIKE); } } } } }
} ?> "> <td><?php echo $i + ($pager->getPage() - 1) * $pager->getMaxPerPage(); ?> </td> <td class='first' align="left"><?php echo $cat_category->getName() ? $cat_category->toString() : '-'; ?> </td> <td align="left"> <?php $c = new Criteria(); $c->add(CatalogPeer::CAT_CATEGORY_ID, $cat_category->getId()); $count_title = CatalogPeer::doCount($c); echo $count_title > 0 ? $count_title : '-'; ?> </td> <td align="left"> <?php $cw = new Criteria(); $cw->add(CatalogPeer::CAT_CATEGORY_ID, $cat_category->getId()); $cw->addJoin(ColItemPeer::CATALOG_ID, CatalogPeer::ID); $count_copies = ColItemPeer::doCount($cw); echo $count_copies > 0 ? $count_copies : '-'; ?> </td> </tr> <?php }
public function executeDelete() { $catalog = CatalogPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($catalog); $c = new Criteria(); $c->add(CatalogEmployeePeer::CATALOG_ID, $catalog->getId()); $ce = CatalogEmployeePeer::doSelectOne($c); $cw = new Criteria(); $cw->add(ColItemPeer::CATALOG_ID, $catalog->getId()); $ci = ColItemPeer::doSelectOne($cw); $ce->delete(); $ci->delete(); $catalog->delete(); return $this->redirect('employee_bank/list'); }
public static function doSelectJoinAll(Criteria $c, $con = null) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } VColItemPerCatalogPeer::addSelectColumns($c); $startcol2 = VColItemPerCatalogPeer::NUM_COLUMNS - VColItemPerCatalogPeer::NUM_LAZY_LOAD_COLUMNS + 1; CatalogPeer::addSelectColumns($c); $startcol3 = $startcol2 + CatalogPeer::NUM_COLUMNS; $c->addJoin(VColItemPerCatalogPeer::ID, CatalogPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = VColItemPerCatalogPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = CatalogPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getCatalog(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addVColItemPerCatalog($obj1); break; } } if ($newObject) { $obj2->initVColItemPerCatalogs(); $obj2->addVColItemPerCatalog($obj1); } $results[] = $obj1; } return $results; }
public static function doSelectJoinAllExceptColLocation(Criteria $c, $con = null) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } VOpacPeer::addSelectColumns($c); $startcol2 = VOpacPeer::NUM_COLUMNS - VOpacPeer::NUM_LAZY_LOAD_COLUMNS + 1; CatalogPeer::addSelectColumns($c); $startcol3 = $startcol2 + CatalogPeer::NUM_COLUMNS; DepartmentPeer::addSelectColumns($c); $startcol4 = $startcol3 + DepartmentPeer::NUM_COLUMNS; CatCategoryPeer::addSelectColumns($c); $startcol5 = $startcol4 + CatCategoryPeer::NUM_COLUMNS; ColStatusPeer::addSelectColumns($c); $startcol6 = $startcol5 + ColStatusPeer::NUM_COLUMNS; $c->addJoin(VOpacPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(VOpacPeer::DEPARTMENT_ID, DepartmentPeer::ID); $c->addJoin(VOpacPeer::CAT_CATEGORY_ID, CatCategoryPeer::ID); $c->addJoin(VOpacPeer::COL_STATUS_ID, ColStatusPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = VOpacPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = CatalogPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getCatalog(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addVOpac($obj1); break; } } if ($newObject) { $obj2->initVOpacs(); $obj2->addVOpac($obj1); } $omClass = DepartmentPeer::getOMClass(); $cls = Propel::import($omClass); $obj3 = new $cls(); $obj3->hydrate($rs, $startcol3); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj3 = $temp_obj1->getDepartment(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { $newObject = false; $temp_obj3->addVOpac($obj1); break; } } if ($newObject) { $obj3->initVOpacs(); $obj3->addVOpac($obj1); } $omClass = CatCategoryPeer::getOMClass(); $cls = Propel::import($omClass); $obj4 = new $cls(); $obj4->hydrate($rs, $startcol4); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj4 = $temp_obj1->getCatCategory(); if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) { $newObject = false; $temp_obj4->addVOpac($obj1); break; } } if ($newObject) { $obj4->initVOpacs(); $obj4->addVOpac($obj1); } $omClass = ColStatusPeer::getOMClass(); $cls = Propel::import($omClass); $obj5 = new $cls(); $obj5->hydrate($rs, $startcol5); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj5 = $temp_obj1->getColStatus(); if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) { $newObject = false; $temp_obj5->addVOpac($obj1); break; } } if ($newObject) { $obj5->initVOpacs(); $obj5->addVOpac($obj1); } $results[] = $obj1; } return $results; }
public function executeShowByMember() { $this->can_add = 0; $this->can_edit = 0; $this->can_remove = 0; $this->catalog = CatalogPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($this->catalog); }
public function filterCollection($c, $filters) { $filters_key = array_keys($filters); foreach ($filters_key as $key) { $value = $filters[$key]; if ($value == '' || $value == null) { continue; } if ($key == 'writer_id') { $c->addJoin(VCatalogPerDeptPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(CatalogWriterPeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogWriterPeer::getTableMap()->getColumn('WRITER_ID'); } elseif ($key == 'code') { $c->addJoin(VCatalogPerDeptPeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogPeer::getTableMap()->getColumn('CODE'); } elseif ($key == 'published_year') { $c->addJoin(VCatalogPerDeptPeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogPeer::getTableMap()->getColumn('PUBLISHED_YEAR'); } elseif ($key == 'title') { $c->addJoin(VCatalogPerDeptPeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogPeer::getTableMap()->getColumn('TITLE'); } elseif ($key == 'cat_category_id') { $c->addJoin(VCatalogPerDeptPeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogPeer::getTableMap()->getColumn('CAT_CATEGORY_ID'); } elseif ($key == 'publisher_id') { $c->addJoin(VCatalogPerDeptPeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogPeer::getTableMap()->getColumn('PUBLISHER_ID'); } elseif ($key == 'writer') { $c->addJoin(VCatalogPerDeptPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(CatalogWriterPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(WriterPeer::ID, CatalogWriterPeer::WRITER_ID); $column = WriterPeer::getTableMap()->getColumn('NAME'); } elseif ($key == 'publisher') { $c->addJoin(VCatalogPerDeptPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(PublisherPeer::ID, CatalogPeer::PUBLISHER_ID); $column = PublisherPeer::getTableMap()->getColumn('NAME'); } elseif ($key == 'DEPARTMENT_ID') { $column = VCatalogPerDeptPeer::getTableMap()->getColumn('DEPARTMENT_ID'); } elseif ($key == 'COL_LOCATION_ID') { $column = VCatalogPerDeptPeer::getTableMap()->getColumn('COL_LOCATION_ID'); } else { $column = VCatalogPerDeptPeer::getTableMap()->getColumn($key); } $name = $column->getFullyQualifiedName(); $creoleType = $column->getCreoleType(); if ($creoleType == CreoleTypes::TIMESTAMP) { $from = $value['from']; $to = $value['to']; if ($from != '' && $from != null) { $c->add($name, $from, Criteria::GREATER_EQUAL); } if ($to != '' && $to != null) { $c->add($name, $to, Criteria::LESS_EQUAL); } } else { if ($creoleType == CreoleTypes::INTEGER || $creoleType == CreoleTypes::BIGINT) { $c->add($name, $value, Criteria::EQUAL); } else { if ($creoleType == CreoleTypes::VARCHAR) { $c->add($name, "%{$value}%", Criteria::LIKE); } else { if ($creoleType == CreoleTypes::NUMERIC) { $c->add($name, $value, Criteria::EQUAL); } } } } } }
public static function doSelectFiltered(Criteria $criteria, $con = null) { return CatalogPeer::doSelect($criteria); }
public function filterLate($c, $filters) { $filters_key = array_keys($filters); foreach ($filters_key as $key) { $value = $filters[$key]; if ($value == '' || $value == null) { continue; } if ($key == 'CODE3') { $c->addJoin(CirHistoryPeer::MEMBER_ID, MemberPeer::ID); $column = MemberPeer::gettableMap()->getColumn('CODE3'); } elseif ($key == 'CODE') { $c->addJoin(CirHistoryPeer::MEMBER_ID, MemberPeer::ID); $column = MemberPeer::gettableMap()->getColumn('CODE'); } elseif ($key == 'NAME') { $c->addJoin(CirHistoryPeer::MEMBER_ID, MemberPeer::ID); $column = MemberPeer::gettableMap()->getColumn('NAME'); } elseif ($key == 'TITLE') { $c->addJoin(ColItemPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(CirHistoryPeer::COL_ITEM_ID, ColItemPeer::ID); $column = CatalogPeer::gettableMap()->getColumn('TITLE'); } elseif ($key == 'department_id') { $c->addJoin(ColItemPeer::COL_LOCATION_ID, ColLocationPeer::ID); $c->addJoin(CirHistoryPeer::COL_ITEM_ID, ColItemPeer::ID); $column = ColLocationPeer::gettableMap()->getColumn('DEPARTMENT_ID'); } else { $column = CirHistoryPeer::getTableMap()->getColumn($key); } $name = $column->getFullyQualifiedName(); $creoleType = $column->getCreoleType(); if ($creoleType == CreoleTypes::TIME) { $from = $value['from']; $to = $value['to']; if ($from != '' && $from != null) { $c->add($name, $from, Criteria::GREATER_EQUAL); } if ($to != '' && $to != null) { $c->addAnd($name, $to, Criteria::LESS_EQUAL); } } else { if ($creoleType == CreoleTypes::INTEGER) { $c->add($name, $value, Criteria::EQUAL); } else { if ($creoleType == CreoleTypes::VARCHAR) { $c->add($name, "%{$value}%", Criteria::LIKE); } } } } }
/** * 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 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 = CatalogPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setParentId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setName($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setDescription($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setIsActive($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setCreatedAt($arr[$keys[5]]); } }
public function getCatalogsJoinCatSubject($criteria = null, $con = null) { include_once 'lib/model/om/BaseCatalogPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collCatalogs === null) { if ($this->isNew()) { $this->collCatalogs = array(); } else { $criteria->add(CatalogPeer::PUBLISHER_ID, $this->getId()); $this->collCatalogs = CatalogPeer::doSelectJoinCatSubject($criteria, $con); } } else { $criteria->add(CatalogPeer::PUBLISHER_ID, $this->getId()); if (!isset($this->lastCatalogCriteria) || !$this->lastCatalogCriteria->equals($criteria)) { $this->collCatalogs = CatalogPeer::doSelectJoinCatSubject($criteria, $con); } } $this->lastCatalogCriteria = $criteria; return $this->collCatalogs; }
public function executeCreateItem() { $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $c = new Criteria(); $c->add(JobPeer::CODE, $this->getModuleName()); $job = JobPeer::doSelectOne($c); $acl = AclPeer::retrieveByPK($group_id, $job->getId()); $this->can_add = $acl->getAddPriv() == 1; $this->can_edit = $acl->getEditPriv() == 1; $this->can_remove = $acl->getRemovePriv() == 1; $catalog = CatalogPeer::retrieveByPk($this->getRequestParameter('catalog_id')); $this->forward404Unless($catalog); $actions = array(array('name' => 'save', 'type' => 'image', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value"))); array_push($actions, array('name' => 'back', 'url' => 'collection/listItem?catalog_id=' . $catalog->getId(), 'color' => 'white')); $this->subtitle = $catalog->toString() . ' - id:' . $catalog->getId(); $this->type = 'add'; $this->col_item = new ColItem(); $this->catalog = $catalog; $this->actions = $actions; $this->setTemplate('editItem'); $actions2 = array(array('name' => '<span>Item Koleksi</span>', 'url' => 'collection/listItem?catalog_id=' . $catalog->getId(), 'color' => 'sky', 'type' => 'direct')); array_unshift($actions2, array('name' => '<span>Manajemen Koleksi</span>', 'url' => "collection/list", 'color' => 'sun')); $this->actions2 = $actions2; }
public function executeCreate() { $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $c = new Criteria(); $c->add(JobPeer::CODE, $this->getModuleName()); $job = JobPeer::doSelectOne($c); $acl = AclPeer::retrieveByPK($group_id, $job->getId()); $this->can_add = $acl->getAddPriv() == 1; $this->can_edit = $acl->getEditPriv() == 1; $this->can_remove = $acl->getRemovePriv() == 1; $catalog = CatalogPeer::retrieveByPk($this->getRequestParameter('catalog_id')); $this->forward404Unless($catalog); $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value"))); #if ($acl->getRemovePriv()) array_push($actions, array('name'=>'delete','url'=>'col_item/delete?id='.$col_item->getId(), 'color'=>'red')); array_push($actions, array('name' => 'cancel', 'url' => 'col_item/list?catalog_id=' . $catalog->getId(), 'color' => 'white')); $this->subtitle = $catalog->toString() . ' - id:' . $catalog->getId(); $this->type = 'add'; $this->col_item = new ColItem(); $this->catalog = $catalog; $this->actions = $actions; $this->setTemplate('create'); }
</tr> <tr class="list" id='filter' <?php if (!isset($filters)) { echo 'style=""'; } ?> > <td class='filter'><?php echo submit_image_tag('/images/magnifier.png', array('class' => 'sort', 'onclick' => "blur();")); ?> </td> <td class='filter_first'> <?php echo input_hidden_tag('filters[id]', isset($filters['id']) ? $filters['id'] : null); if (isset($filters['id']) && $filters['id']) { echo input_auto_complete_tag('catalog_code', isset($filters['id']) && $filters['id'] ? CatalogPeer::retrieveByPk($filters['id'])->toString() : '', '/catalog/getList', array('size' => 80), array('after_update_element' => 'function(f, s) {$("id").updateFromInformalAutocomplete(f, s);}', 'min_chars' => 1)); } else { echo input_auto_complete_tag('catalog_code', null, '/catalog/getList', array('size' => 80), array('after_update_element' => 'function(f, s) {$("filters_id").updateFromInformalAutocomplete(f, s);}', 'min_chars' => 1)); } #echo input_tag('filters[code]', isset($filters['code']) ? $filters['code'] : null, array ( 'size' => 15, )) ?> <?php /** echo input_hidden_tag('filters[catalog_id]',isset($filters['catalog_id']) ? $filters['catalog_id'] : null); echo input_auto_complete_tag( 'catalog_code', isset($filters['catalog_id']) ? CatalogPeer::retrieveByPk($filters['catalog_id'])->toString() : null, '/catalog/getList', array('size'=>64), array('after_update_element'=>'function(f, s) {$("filters_catalog_id").updateFromInformalAutocomplete(f, s);}') );
public function executeView() { $this->catalog = CatalogPeer::retrieveByPk($this->getRequestParameter('catalog_id')); $c = new Criteria(); $c->add(ColItemPeer::CATALOG_ID, $this->catalog->getId()); $c->addAscendingOrderByColumn(ColItemPeer::CATALOG_ID); $pager = new sfPropelPager('ColItem', $this->getRequestParameter('max_per_page', 10)); $pager->setCriteria($c); $pager->setPage($this->getRequestParameter('page', 1)); $pager->init(); $this->pager = $pager; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = CatalogPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setCode($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setCatLanguageId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setCatCategoryId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setCatSubjectId($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setTitle($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setSubtitle($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setPublisherId($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setPublishedYear($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setPublishedLocation($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setIsbn($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setStudentNo($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setStudentName($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setStudentMajor($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setStudentTutor($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setVersion($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setEdition($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setPrintNo($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setPart($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setVolume($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setMonth($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setYear($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setNo($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { $this->setBonus($arr[$keys[23]]); } if (array_key_exists($keys[24], $arr)) { $this->setPages($arr[$keys[24]]); } if (array_key_exists($keys[25], $arr)) { $this->setHeight($arr[$keys[25]]); } if (array_key_exists($keys[26], $arr)) { $this->setSynopsis($arr[$keys[26]]); } if (array_key_exists($keys[27], $arr)) { $this->setAbstracts($arr[$keys[27]]); } if (array_key_exists($keys[28], $arr)) { $this->setSearchKeywords($arr[$keys[28]]); } if (array_key_exists($keys[29], $arr)) { $this->setCreatedAt($arr[$keys[29]]); } if (array_key_exists($keys[30], $arr)) { $this->setUpdatedAt($arr[$keys[30]]); } }
public static function doSelectJoinAllExceptColSource(Criteria $c, $con = null) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } ColItemPeer::addSelectColumns($c); $startcol2 = ColItemPeer::NUM_COLUMNS - ColItemPeer::NUM_LAZY_LOAD_COLUMNS + 1; CatalogPeer::addSelectColumns($c); $startcol3 = $startcol2 + CatalogPeer::NUM_COLUMNS; ColStatusPeer::addSelectColumns($c); $startcol4 = $startcol3 + ColStatusPeer::NUM_COLUMNS; ColConditionPeer::addSelectColumns($c); $startcol5 = $startcol4 + ColConditionPeer::NUM_COLUMNS; MemberPeer::addSelectColumns($c); $startcol6 = $startcol5 + MemberPeer::NUM_COLUMNS; ColLocationPeer::addSelectColumns($c); $startcol7 = $startcol6 + ColLocationPeer::NUM_COLUMNS; $c->addJoin(ColItemPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(ColItemPeer::COL_STATUS_ID, ColStatusPeer::ID); $c->addJoin(ColItemPeer::COL_CONDITION_ID, ColConditionPeer::ID); $c->addJoin(ColItemPeer::MEMBER_ID, MemberPeer::ID); $c->addJoin(ColItemPeer::COL_LOCATION_ID, ColLocationPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = ColItemPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = CatalogPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getCatalog(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addColItem($obj1); break; } } if ($newObject) { $obj2->initColItems(); $obj2->addColItem($obj1); } $omClass = ColStatusPeer::getOMClass(); $cls = Propel::import($omClass); $obj3 = new $cls(); $obj3->hydrate($rs, $startcol3); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj3 = $temp_obj1->getColStatus(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { $newObject = false; $temp_obj3->addColItem($obj1); break; } } if ($newObject) { $obj3->initColItems(); $obj3->addColItem($obj1); } $omClass = ColConditionPeer::getOMClass(); $cls = Propel::import($omClass); $obj4 = new $cls(); $obj4->hydrate($rs, $startcol4); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj4 = $temp_obj1->getColCondition(); if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) { $newObject = false; $temp_obj4->addColItem($obj1); break; } } if ($newObject) { $obj4->initColItems(); $obj4->addColItem($obj1); } $omClass = MemberPeer::getOMClass(); $cls = Propel::import($omClass); $obj5 = new $cls(); $obj5->hydrate($rs, $startcol5); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj5 = $temp_obj1->getMember(); if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) { $newObject = false; $temp_obj5->addColItem($obj1); break; } } if ($newObject) { $obj5->initColItems(); $obj5->addColItem($obj1); } $omClass = ColLocationPeer::getOMClass(); $cls = Propel::import($omClass); $obj6 = new $cls(); $obj6->hydrate($rs, $startcol6); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj6 = $temp_obj1->getColLocation(); if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) { $newObject = false; $temp_obj6->addColItem($obj1); break; } } if ($newObject) { $obj6->initColItems(); $obj6->addColItem($obj1); } $results[] = $obj1; } return $results; }
public function getCatalog($con = null) { include_once 'lib/model/om/BaseCatalogPeer.php'; if ($this->aCatalog === null && $this->catalog_id !== null) { $this->aCatalog = CatalogPeer::retrieveByPK($this->catalog_id, $con); } return $this->aCatalog; }
public function executeSimpan() { $i18n = new sfI18N(); $i18n->initialize($this->getContext()); $i18n->setCulture($this->getUser()->getCulture()); $action_i18n = $i18n->globalMessageFormat->format('save as new'); $action_edit_i18n = $i18n->globalMessageFormat->format('edit'); $action_type = $this->getRequestParameter('action_type'); if ($action_type == $action_i18n || !$this->getRequestParameter('id', 0)) { $catalog = new Catalog(); } else { $catalog = CatalogPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($catalog); } $catalog->setId($this->getRequestParameter('id')); $catalog->setCatLanguageId(1); $catalog->setCatCategoryId(15); $catalog->setCatSubjectId(4202); $catalog->setTitle($this->getRequestParameter('title')); $catalog->setPublishedYear(2011); $catalog->setPublishedLocation('Jakarta'); $catalog->setSynopsis($this->getRequestParameter('synopsis')); $catalog->setSearchKeywords($this->getRequestParameter('search_keywords')); $catalog->setPublisherId(8682); $catalog->save(); $cw = new CatalogWriter(); $cw->setCatalog($catalog); $cw->setWriterId(8112); $cw->save(); $writer_name = $catalog->getFirstWriterName(); $writer_name = preg_replace('/\\W+/', '', $writer_name); $writer_name = strtoupper(substr($writer_name, 0, 3)); $title = substr(strtoupper(str_replace(' ', '', $catalog->getTitle())), 0, 3); $subject_code = $catalog->getCatSubject()->getCode(); $catalog->setCode("{$subject_code}-{$writer_name}-{$title}"); $catalog->save(); if ($this->hasRequestParameter('copies') && $this->getRequestParameter('copies') > 0) { $catalog->addCopies($this); } $cover_dir = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR; if ($this->hasRequestParameter('coverFile') && $this->getRequestParameter('coverFile') != '' && $this->getRequestParameter('coverFile') != null) { // get cover content $cover_file = $cover_dir . 'tmp' . DIRECTORY_SEPARATOR . $this->getRequestParameter('coverFile'); $content = file_get_contents($cover_file); $im = imagecreatefromstring($content); list($w, $h) = getimagesize($cover_file); // generate cover $cover = imagecreatetruecolor(150, 200); imagecopyresized($cover, $im, 0, 0, 0, 0, 150, 200, $w, $h); // generate thumbnail $thumb = imagecreatetruecolor(100, 150); imagecopyresized($thumb, $im, 0, 0, 0, 0, 100, 150, $w, $h); // get cover record $c = new Criteria(); $c->add(CatalogCopiedPeer::CATALOG_ID, $catalog->getId()); $catalog_cover = CatalogCopiedPeer::doSelectOne($c); if ($catalog_cover == null) { $catalog_cover = new CatalogCopied(); $catalog_cover->setCatalog($catalog); } // save cover imagepng($cover, $cover_file); $catalog_cover->setCover(base64_encode(file_get_contents($cover_file))); imagepng($thumb, $cover_file); $catalog_cover->setThumbnail(base64_encode(file_get_contents($cover_file))); $catalog_cover->save(); unlink($cover_dir . 'tmp' . DIRECTORY_SEPARATOR . $this->getRequestParameter('coverFile')); } if ($this->hasRequestParameter('file') && $this->getRequestParameter('file') != '' && $this->getRequestParameter('file') != null) { $fileName = $this->getRequestParameter('file'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_1') && $this->getRequestParameter('file_1') != '' && $this->getRequestParameter('file_1') != null) { $fileName = $this->getRequestParameter('file_1'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_2') && $this->getRequestParameter('file_2') != '' && $this->getRequestParameter('file_2') != null) { $fileName = $this->getRequestParameter('file_2'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_3') && $this->getRequestParameter('file_3') != '' && $this->getRequestParameter('file_3') != null) { $fileName = $this->getRequestParameter('file_3'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_4') && $this->getRequestParameter('file_4') != '' && $this->getRequestParameter('file_4') != null) { $fileName = $this->getRequestParameter('file_4'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_5') && $this->getRequestParameter('file_5') != '' && $this->getRequestParameter('file_5') != null) { $fileName = $this->getRequestParameter('file_5'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_6') && $this->getRequestParameter('file_6') != '' && $this->getRequestParameter('file_6') != null) { $fileName = $this->getRequestParameter('file_6'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_7') && $this->getRequestParameter('file_7') != '' && $this->getRequestParameter('file_7') != null) { $fileName = $this->getRequestParameter('file_7'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_8') && $this->getRequestParameter('file_8') != '' && $this->getRequestParameter('file_8') != null) { $fileName = $this->getRequestParameter('file_8'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_9') && $this->getRequestParameter('file_9') != '' && $this->getRequestParameter('file_9') != null) { $fileName = $this->getRequestParameter('file_9'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } if ($this->hasRequestParameter('file_10') && $this->getRequestParameter('file_10') != '' && $this->getRequestParameter('file_10') != null) { $fileName = $this->getRequestParameter('file_10'); $catalog_file = new CatalogFile(); $catalog_file->setCatalog($catalog); $catalog_file->setFile($fileName); $catalog_file->save(); } $dept_id = $this->getContext()->getUser()->getAttribute('department_id', null, 'bo'); $dept = $this->getContext()->getUser()->getAttribute('department', null, 'bo'); if ($dept_id == 2) { $c = new Criteria(); $c->add(ColItemPeer::CATALOG_ID, $catalog->getId()); $ci = ColItemPeer::doSelectOne($c); $ci->setColLocationId(102); $ci->save(); } elseif ($dept_id == 3) { $c = new Criteria(); $c->add(ColItemPeer::CATALOG_ID, $catalog->getId()); $ci = ColItemPeer::doSelectOne($c); $ci->setColLocationId(103); $ci->save(); } else { $c = new Criteria(); $c->add(ColItemPeer::CATALOG_ID, $catalog->getId()); $ci = ColItemPeer::doSelectOne($c); $ci->setColLocationId(104); $ci->save(); } return $this->redirect('catalog/listBank'); }