Ejemplo n.º 1
0
 public static function deletePhotographer($photog)
 {
     $c1 = new Criteria();
     $c1->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $photog->getId());
     JobPhotographerPeer::doDelete($c1);
     $photog->delete();
 }
Ejemplo n.º 2
0
 protected function createAdvancedSearchCriteria($arr)
 {
     $c = new Criteria();
     if (strlen($arr['jobStatus'])) {
         $c->add(JobPeer::STATUS_ID, $arr["jobStatus"]);
     }
     if (!is_null($arr["dueDateStart"])) {
         $c->add(JobPeer::DUE_DATE, $arr["dueDateStart"], Criteria::GREATER_EQUAL);
     }
     if (!is_null($arr["dueDateEnd"])) {
         $c->addAnd(JobPeer::DUE_DATE, $arr["dueDateEnd"], Criteria::LESS_EQUAL);
     }
     if (!is_null($arr["shootDateStart"])) {
         $c->add(JobPeer::DATE, $arr["shootDateStart"], Criteria::GREATER_EQUAL);
     }
     if (!is_null($arr["shootDateEnd"])) {
         $c->addAnd(JobPeer::DATE, $arr["shootDateEnd"], Criteria::LESS_EQUAL);
     }
     if (strlen($arr["clientId"])) {
         $jobIds = JobClientPeer::getJobsByClientId($arr["clientId"]);
         $c->add(JobPeer::ID, $jobIds, Criteria::IN);
     }
     if (strlen($arr["photographerId"])) {
         $jobIds = JobPhotographerPeer::getJobsByPhotographerId($arr["photographerId"]);
         $c->addAnd(JobPeer::ID, $jobIds, Criteria::IN);
     }
     if ($arr["sortDirection"] == 1) {
         $c->addDescendingOrderByColumn($arr["sortOn"]);
     } else {
         $c->addAscendingOrderByColumn($arr["sortOn"]);
     }
     return $c;
 }
Ejemplo n.º 3
0
 public function executeViewJobs(sfWebRequest $request)
 {
     $this->photographer = $this->getRoute()->getObject();
     $ids = JobPhotographerPeer::getJobsByPhotographerId($this->photographer->getId());
     $c = new Criteria();
     $c->add(JobPeer::ID, $ids, Criteria::IN);
     $this->getPager($c, array("route" => "photographer_view_jobs", "slugOn" => "slug", "slug" => $this->photographer->getSlug()));
 }
Ejemplo n.º 4
0
 public static function getJobsByPhotographerId($photogId)
 {
     $c = new Criteria();
     $c->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $photogId);
     $obj = JobPhotographerPeer::doSelect($c);
     $ids = array();
     foreach ($obj as $i) {
         $ids[] = $i->getJobId();
     }
     return $ids;
 }
Ejemplo n.º 5
0
 private function reloadByPhotographer($photographerId)
 {
     $c = new Criteria();
     $this->routeObject = PhotographerPeer::retrieveByPK($photographerId);
     $ids = JobPhotographerPeer::getJobsByPhotographerId($photographerId);
     $c->add(JobPeer::ID, $ids, Criteria::IN);
     $this->route = "photographer_view_jobs";
     $this->propelType = "slug";
     $this->renderStatus = true;
     $this->viewingCaption = " jobs for " . $this->routeObject->getName();
     return $c;
 }
Ejemplo n.º 6
0
 public function removePhotographer($photographer)
 {
     $c = new Criteria();
     $c->add(JobPhotographerPeer::JOB_ID, $this->getId());
     $c->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $photographer->getId());
     JobPhotographerPeer::doDelete($c);
     $logEntry = new Log();
     $logEntry->setWhen(time());
     $logEntry->setPropelClass("Job");
     $logEntry->setSfGuardUserProfileId(sfContext::getInstance()->getUser()->getUserId());
     $logEntry->setMessage($photographer->getName() . " removed from job.");
     $logEntry->setLogMessageTypeId(sfConfig::get("app_log_type_remove_photographer"));
     $logEntry->setPropelId($this->getId());
     $logEntry->save();
 }
Ejemplo n.º 7
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->page = $this->getRequest()->getParameter("page");
     $this->sortedBy = $this->getRequest()->getParameter("sortBy");
     $this->invert = $this->getRequest()->getParameter("invert");
     $own = $request->getParameter("own");
     $all = $request->getParameter("all");
     $this->all = $all;
     $this->own = $own;
     $profile = $this->getUser()->getProfile();
     if (is_null($all)) {
         $all = false;
     }
     if (is_null($own)) {
         $own = false;
     }
     $c = new Criteria();
     if ($own) {
         $crit = new Criteria();
         $crit->add(ClientPeer::USER_ID, $profile->getId());
         $client = ClientPeer::doSelectOne($crit);
         if (is_null($client)) {
             $this->forward404("Please contact Tufts Photo support.");
         }
         $crit = new Criteria();
         $ids = array();
         $crit->add(JobClientPeer::CLIENT_ID, $client->getId());
         $jobs = JobClientPeer::doSelectJoinAll($crit);
         foreach ($jobs as $ph) {
             $ids[] = $ph->getJobId();
         }
         $c->add(JobPeer::ID, $ids, Criteria::IN);
     } else {
         // $c->add(JobPeer::STATUS_ID, sfConfig::get("job_status_pending"));
         $c = new Criteria();
         $crit0 = $c->getNewCriterion(JobPeer::STATUS_ID, sfConfig::get("app_job_status_pending"));
         $crit1 = $c->getNewCriterion(JobPeer::STATUS_ID, sfConfig::get("app_job_status_accepted"));
         $crit2 = $c->getNewCriterion(JobPeer::STATUS_ID, sfConfig::get("app_job_status_completed"));
         // Perform OR at level 0 ($crit0 $crit1 $crit2 )
         $crit0->addOr($crit1);
         $crit0->addOr($crit2);
         // Remember to change the peer class here for the correct one in your model
         $c->add($crit0);
     }
     // restrict to only their jobs if they are photogs
     if ($profile->getUserType()->getId() == sfConfig::get("app_user_type_photographer")) {
         $crit = new Criteria();
         $crit->add(PhotographerPeer::USER_ID, $profile->getId());
         $photo = PhotographerPeer::doSelectOne($crit);
         if (is_null($photo)) {
             $this->forward404("Please contact Tufts Photo support.");
         }
         $crit = new Criteria();
         $crit->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $photo->getId());
         $ids = array();
         $photos = JobPhotographerPeer::doSelectJoinAll($crit);
         foreach ($photos as $ph) {
             $ids[] = $ph->getJobId();
         }
         $c->add(JobPeer::ID, $ids, Criteria::IN);
     }
     if (is_null($this->sortedBy)) {
         $this->sortedBy = JobPeer::DATE;
     }
     if (is_null($this->invert) || $this->invert == "false") {
         $this->invert = false;
         $c->addAscendingOrderByColumn($this->sortedBy);
     } else {
         $c->addDescendingOrderByColumn($this->sortedBy);
         $this->invert = true;
     }
     if (!is_numeric($this->page)) {
         $this->page = 1;
     }
     $this->pager = new sfPropelPager("Job", sfConfig::get("app_items_per_page"));
     $this->pager->setCriteria($c);
     $this->pager->setPage($this->page);
     $this->pager->setPeerMethod("doSelectJoinAll");
     $this->pager->init();
     $this->results = $this->pager->getResults();
     sfPropelActAsTaggableBehavior::preloadTags($this->results);
     $sortUrls = array();
     foreach (JobPeer::$LIST_VIEW_SORTABLE as $key => $val) {
         $sortUrls[$key]["true"] = $this->generateUrl("client_myjobs_own", array("own" => $own, "all" => $all, "sortBy" => $key, "invert" => "true"));
         $sortUrls[$key]["false"] = $this->generateUrl("client_myjobs_own", array("own" => $own, "all" => $all, "sortBy" => $key, "invert" => "false"));
     }
     $this->sortUrlJson = json_encode($sortUrls);
 }
Ejemplo n.º 8
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 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 = JobPhotographerPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setPhotographerId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setJobId($arr[$keys[2]]);
     }
 }
Ejemplo n.º 9
0
function renderClientJobListView($job, $classNum, $canAdd)
{
    ?>
  <div class="job-list-item-<?php 
    echo $classNum;
    ?>
">
	  <?php 
    $sTime = $job->getStartTime();
    $eTime = $job->getEndTime();
    $sTime = substr($sTime, -8, 5);
    $eTime = substr($eTime, -8, 5);
    ?>
    <table class="job-table" width="100%">
			<col width="33%"></col>
			<col width="33%"></col>
	    <tr>
	     <td>
	       <?php 
    if (sfContext::getInstance()->getUser()->hasCredential("client")) {
        ?>
		       <?php 
        if (JobClientPeer::isOwner($job->getId(), sfContext::getInstance()->getUser()->getProfile()->getId())) {
            ?>
		         Job <?php 
            echo link_to($job->getId(), "clientview_job_show", $job);
            ?>
		       <?php 
        } else {
            ?>
		         Job <?php 
            echo $job->getId();
            ?>
		       <?php 
        }
        ?>
	       <?php 
    }
    ?>
	       
	      <?php 
    if (sfContext::getInstance()->getUser()->hasCredential("photographer")) {
        ?>
           <?php 
        if (JobPhotographerPeer::isOwner($job->getId(), sfContext::getInstance()->getUser()->getProfile()->getId())) {
            ?>
             Job <?php 
            echo link_to($job->getId(), "clientview_job_show", $job);
            ?>
           <?php 
        } else {
            ?>
             Job <?php 
            echo $job->getId();
            ?>
           <?php 
        }
        ?>
        <?php 
    }
    ?>
	       
	     </td>
		   <td><?php 
    echo $job->getEvent();
    ?>
</td>
		   
		   <?php 
    if ($canAdd && sfContext::getInstance()->getUser()->hasCredential("client")) {
        ?>
		    <td><?php 
        echo link_to_function("Add me as client", "addClient(" . $job->getId() . ")");
        ?>
</td>
		   <?php 
    }
    ?>
		   <td><?php 
    if ($job->getProjectId()) {
        $title = $job->getProject()->getName();
        $title = substr($title, 0, 30) == $title ? $title : substr($title, 0, 30) . "...";
        echo "In " . $job->getProject();
    }
    ?>
</td>
	     </tr>
	     <tr>
	 	   <td><?php 
    echo $job->getDate("F j, Y") . " " . $sTime . " - " . $eTime;
    ?>
 </td>
	 	   <td><?php 
    $clients = $job->getClients();
    if (count($clients) == 0) {
        echo "No Clients";
    } else {
        echo "For ";
        foreach ($clients as $c) {
            echo $c->getName() . " ";
        }
    }
    ?>
</td> 
       <?php 
    $photogs = $job->getPhotographers();
    if (count($photogs) == 1) {
        foreach ($photogs as $i) {
            ?>
           <td>
           <?php 
            echo $i . " ";
            ?>
           </td>
        <?php 
        }
        ?>
        <?php 
    }
    ?>
        
	      <?php 
    if (count($photogs) == 0) {
        ?>
           <td> <?php 
        echo "No Photographer";
        ?>
 </td>
        <?php 
    }
    ?>
	      
        <?php 
    if (count($photogs) > 1) {
        ?>
           <td> <?php 
        echo count($photogs) . " Photographers";
        ?>
 </td>
       <?php 
    }
    ?>
        </tr>
</table>
</div>
<?php 
}
Ejemplo n.º 10
0
 public function getNumberOfJobs()
 {
     $c = new Criteria();
     $c->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $this->getId());
     return JobPhotographerPeer::doCount($c);
 }
Ejemplo n.º 11
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Photographer is new, it will return
  * an empty collection; or if this Photographer has previously
  * been saved, it will retrieve related JobPhotographers from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Photographer.
  */
 public function getJobPhotographersJoinJob($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(PhotographerPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collJobPhotographers === null) {
         if ($this->isNew()) {
             $this->collJobPhotographers = array();
         } else {
             $criteria->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $this->id);
             $this->collJobPhotographers = JobPhotographerPeer::doSelectJoinJob($criteria, $con, $join_behavior);
         }
     } else {
         // 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 the collection.
         $criteria->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $this->id);
         if (!isset($this->lastJobPhotographerCriteria) || !$this->lastJobPhotographerCriteria->equals($criteria)) {
             $this->collJobPhotographers = JobPhotographerPeer::doSelectJoinJob($criteria, $con, $join_behavior);
         }
     }
     $this->lastJobPhotographerCriteria = $criteria;
     return $this->collJobPhotographers;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @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(JobPhotographerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(JobPhotographerPeer::DATABASE_NAME);
         $criteria->add(JobPhotographerPeer::ID, $pks, Criteria::IN);
         $objs = JobPhotographerPeer::doSelect($criteria, $con);
     }
     return $objs;
 }