public function transformJobs() { $statusHash = array(); $statusObjects = StatusPeer::doSelect(new Criteria()); foreach ($statusObjects as $s) { $statusHash[$s->getState()] = $s->getId(); } $this->jobKeys = array(); $dom = DOMDocument::load("tuftsph_jm2db.xml"); $jobs = $dom->getElementsByTagName("jobs"); $total = $jobs->length; $count = 1; $jobList = array(); foreach ($jobs as $job) { $jid = 0; $childNodes = $job->childNodes; $j = new Job(); $del = new Delivery(); $jid = 1; $startTime = null; $shootStart = null; $shootEnd = null; $endTime = null; $notes = ""; $photog = 0; $slug = ""; $childNodes = $job->childNodes; foreach ($childNodes as $child) { switch ($child->nodeName) { case "id": $jid = $child->textContent; break; case "shoot_name": $j->setEvent($child->textContent); break; case "shoot_date": $j->setDate($child->textContent); break; case "shoot_startT": $startTime = $child->textContent; break; case "shoot_start": $shootStart = $child->textContent; break; case "shoot_endT": $endTime = $child->textContent; break; case "shoot_end": $shootEnd = $child->textContent; break; case "shoot_duedate": $j->setDueDate($child->textContent); break; case "submitted_at": $j->setCreatedAt($child->textContent); break; case "requester_address": $j->setStreet($child->textContent); break; case "requester_campus": $j->setCity($child->textContent); break; case "requester_name": $j->setContactName($child->textContent); break; case "requester_email": $j->setContactEmail($child->textContent); break; case "requester_phone": $j->setContactPhone($child->textContent); break; case "internal_notes": $notes .= $child->textContent . "<br/>"; break; case "billing_notes": $notes .= $child->textContent . "<br/>"; break; case "estimate": $j->setEstimate($child->textContent); break; case "billing_acctnum": $j->setAcctNum($child->textContent); break; case "billing_deptid": $j->setDeptId($child->textContent); break; case "billing_grantid": $j->setGrantId($child->textContent); break; case "shoot_directions": $j->setOther($child->textContent); break; case "status": $j->setStatusId($statusHash[$child->textContent]); break; case "photog_id": $photog = $child->textContent; break; case "delivery_pubname": $del->setPubName($child->textContent); break; case "delivery_pubtype": $del->setPubType($child->textContent); break; case "delivery_other": $del->setOther($child->textContent); break; case "delivery_format": break; case "delivery_color": $del->setColor($child->textContent); break; case "delivery_format": $del->setFormat($child->textContent); break; case "delivery_size": $del->setSize($child->textContent); break; case "delivery_method": $del->setMethod($child->textContent); break; case "delivery_special": $del->setInstructions($child->textContent); break; case "slug": $slug = $child->textContent; break; case "#text": default: break; } } if (is_null($endTime)) { $endTime = $shootEnd; } if (is_null($startTime)) { $startTime = $shootStart; } if ($j->getCity() == "Boston") { $j->setZip("02101"); } else { $j->setZip("02155"); } $j->setNotes($notes); $j->setState("Massachusetts"); list($hour, $min, $sec) = explode(":", $endTime); list($shour, $smin, $ssec) = explode(":", $startTime); $t = new DateTime(); $t->setTime($hour, $min, $sec); $j->setEndTime($t); $t = new DateTime(); $t->setTime($shour, $smin, $ssec); $j->setStartTime($t); $j->addTag($slug); if (isset($this->jobProjectKeys[$jid])) { $j->setProjectId($this->projectKeys[$this->jobProjectKeys[$jid]]); } while (count($jobList) - 1 != $jid) { $jobList[] = false; } $jobList[intval($jid)] = array("job" => $j, "del" => $del, "photog" => $photog); } for ($i = 1; $i < count($jobList); $i++) { sleep(1); $obj = $jobList[$i]; $c = new Criteria(); $c->add(JobPeer::ID, $i); if (JobPeer::doCount($c) > 0) { continue; } echo $i . "/" . $total . "\n"; // keep the ids lined up if ($obj == false) { $myJob = new Job(); try { $myJob->save(); } catch (Exception $ex) { echo $ex->getMessage(); } $myJob->delete(); } else { $j = $obj["job"]; $del = $obj["del"]; $photog = $obj["photog"]; try { $j->save(); } catch (Exception $ex) { echo $ex->getMessage(); echo $ex->getTraceAsString(); } $del->setJobId($j->getId()); $del->save(); $this->jobKeys[$jid] = $j->getId(); if ($photog) { $jp = new JobPhotographer(); $jp->setPhotographerId($this->photogKeys[$photog]); $jp->setJobId($j->getId()); try { $jp->save(); } catch (Exception $ex) { echo $ex->getMessage(); } } // add the requester as a client $c = new Criteria(); $c->add(sfGuardUserPeer::USERNAME, $j->getContactEmail()); if (ClientPeer::doCount($c) == 0 && trim(strlen($j->getContactEmail())) != 0) { $user = new sfGuardUser(); $user->setUsername($j->getContactEmail()); $user->setPassword("admin"); $user->save(); $userProfile = new sfGuardUserProfile(); $userProfile->setUserId($user->getId()); $userProfile->setUserTypeId(sfConfig::get("app_user_type_client")); $userProfile->save(); $clientProfile = new Client(); $clientProfile->setUserId($userProfile->getId()); $clientProfile->setName($j->getContactName()); $clientProfile->setEmail($j->getContactEmail()); $clientProfile->setPhone($j->getContactPhone()); $clientProfile->save(); $jobClient = new JobClient(); $jobClient->setClientId($clientProfile->getId()); $jobClient->setJobId($j->getId()); $jobClient->save(); } } $count += 1; } }
public function getNumberOfJobs() { $c = new Criteria(); $c->add(JobPeer::PROJECT_ID, $this->getId()); return JobPeer::doCount($c); }
public function executeEdit() { $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()); if (!$acl) { $this->forward('default', 'error404'); } $this->can_add = $acl->getAddPriv() == 1; $this->can_edit = $acl->getEditPriv() == 1; $this->can_remove = $acl->getRemovePriv() == 1; $user_group = UserGroupPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($user_group); if ($user_group->getJobTemplateId() == 11) { $c = new Criteria(); $cton1 = $c->getNewCriterion(JobPeer::ID, 132, Criteria::NOT_IN); $cton2 = $c->getNewCriterion(JobPeer::JOB_TEMPLATE_ID, 1, Criteria::IN); $cton3 = $c->getNewCriterion(JobPeer::JOB_TEMPLATE_ID, 3, Criteria::IN); $cton4 = $c->getNewCriterion(JobPeer::JOB_TEMPLATE_ID, 11, Criteria::IN); $cton3->addOr($cton4); $cton2->addOr($cton3); $cton1->addAnd($cton2); $c->add($cton1); $c->addAscendingOrderByColumn(JobPeer::MENU_ORDER); $jobs = JobPeer::doSelect($c); } else { $c = new Criteria(); $cton1 = $c->getNewCriterion(JobPeer::ID, 132, Criteria::NOT_IN); $cton2 = $c->getNewCriterion(JobPeer::JOB_TEMPLATE_ID, $user_group->getJobTemplateId(), Criteria::IN); $cton3 = $c->getNewCriterion(JobPeer::JOB_TEMPLATE_ID, $user_group->getJobTemplate()->getParent(), Criteria::IN); $cton4 = $c->getNewCriterion(JobPeer::JOB_TEMPLATE_ID, 11, Criteria::IN); $cton3->addOr($cton4); $cton2->addOr($cton3); $cton1->addAnd($cton2); $c->add($cton1); $c->addAscendingOrderByColumn(JobPeer::MENU_ORDER); $jobs = JobPeer::doSelect($c); } foreach ($jobs as $job) { $c = new Criteria(); $c->add(JobPeer::PARENT, $job->getId()); $c->add(JobPeer::DISPLAY_MENU, true); $job->child = JobPeer::doCount($c); $c = new Criteria(); $c->add(AclPeer::USER_GROUP_ID, $user_group->getId(), Criteria::EQUAL); $c->add(AclPeer::JOB_ID, $job->getId(), Criteria::EQUAL); $job->acl = AclPeer::doSelectOne($c); $job->level = $job->getLevel(); $job->order = $job->getMenuOrderRecursive(); } $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value"))); if ($user_group->getCode() != 'admin' && $user_group->getCode() != 'student' && $user_group->getCode() != 'lector') { array_push($actions, array('name' => 'delete', 'url' => 'user_group/delete?id=' . $user_group->getId(), 'color' => 'red')); } array_push($actions, array('name' => 'cancel', 'url' => 'user_group/list', 'color' => 'white')); $this->subtitle = $user_group->toString() . ' - id:' . $user_group->getId(); $this->type = 'edit'; $this->user_group = $user_group; $this->icon = 'user_edit.png'; $this->actions = $actions; $this->jobs = $jobs; }
public function countJobs($criteria = null, $distinct = false, $con = null) { include_once 'lib/model/om/BaseJobPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(JobPeer::JOB_TEMPLATE_ID, $this->getId()); return JobPeer::doCount($criteria, $distinct, $con); }
<?php $i = 0; foreach ($rows as $job) { $c = new Criteria(); $c->add(JobPeer::PARENT, $job->getId()); $job->child = JobPeer::doCount($c); $code_level = ''; for ($i = 0; $i < $level; $i++) { $code_level .= ParamsPeer::retrieveByCode('tree_node_mark')->getValue(); } ?> <tr id='job_<?php echo $job->getId(); ?> ' class="list<?php ++$i; if ($i % 2 == 0) { echo ' even'; } ?> <?php echo $parent_class; ?> job_<?php echo $parent_id; ?> _child"> <td id='job_<?php echo $job->getId(); ?>
/** * Returns the number of related Job objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Job objects. * @throws PropelException */ public function countJobs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(ProjectPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collJobs === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(JobPeer::PROJECT_ID, $this->id); $count = JobPeer::doCount($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return count of the collection. $criteria->add(JobPeer::PROJECT_ID, $this->id); if (!isset($this->lastJobCriteria) || !$this->lastJobCriteria->equals($criteria)) { $count = JobPeer::doCount($criteria, $con); } else { $count = count($this->collJobs); } } else { $count = count($this->collJobs); } } return $count; }
public function executeMenu() { $group = $this->getContext()->getUser()->getAttribute('group', null, 'bo'); $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo'); $employee = EmployeePeer::retrieveByPK($employee_id); var_dump($employee); die; $code = $this->getRequest()->getParameter('code'); if ($code == 'acm') { #if ($group == 'admin' || $group == 'root') { if ($group == 'root') { $jobs = array(); $job = new Job(); $job->setName('Modul'); $job->setCode('job'); $job->child = 0; array_push($jobs, $job); $job = new Job(); $job->setName('Parameters'); $job->setCode('params'); $job->child = 0; array_push($jobs, $job); $job = new Job(); $job->setName('Template Koleksi'); $job->setCode('cat_template'); $job->child = 0; array_push($jobs, $job); $job = new Job(); $job->setName('Template Menu'); $job->setCode('menu_template'); $job->child = 0; array_push($jobs, $job); } else { $this->forward('default', 'index'); } } elseif ($code == 'user' || $code == 'user_group' || $code == 'job') { if ($group == 'admin' || $group == 'root') { $this->forward($code, 'index'); } else { $this->forward('default', 'index'); } } else { $c = new Criteria(); $c->addAscendingOrderByColumn('menu_order'); $c->add(JobPeer::CODE, $code); $parent = JobPeer::doSelectOne($c); $c = new Criteria(); $c->add(JobPeer::PARENT, $parent->getId()); $c->addJoin(JobPeer::ID, AclPeer::JOB_ID, Criteria::JOIN); $c->addJoin(AclPeer::USER_GROUP_ID, UserGroupPeer::ID, Criteria::JOIN); $c->add(UserGroupPeer::ID, $group_id, Criteria::EQUAL); $c->add(JobPeer::DISPLAY_MENU, true); $jobs = JobPeer::doSelect($c); // restrict some access to iglobal only $jobs0 = array(); $user = $this->getUser()->getAttribute('username', null, 'bo'); for ($i = 0; $i < count($jobs); ++$i) { if ($user == 'iglobal' || $user == 'syarif') { $jobs0[count($jobs0)] = $jobs[$i]; } else { if ($jobs[$i]->getCode() != 'sm_check' && $jobs[$i]->getCode() != 'sm_template') { $jobs0[count($jobs0)] = $jobs[$i]; } } } $jobs = $jobs0; foreach ($jobs as $job) { $c = new Criteria(); $c->add(JobPeer::PARENT, $job->getId()); $c->add(JobPeer::DISPLAY_MENU, true); $job->child = JobPeer::doCount($c); } } $this->jobs = $jobs; $this->type = $this->getRequest()->getParameter('get'); }