Permalink
Browse files

Correct first problem in loans

  • Loading branch information...
1 parent 85e7121 commit 7ae6536cc3447902204c684db28bb8e767f72d06 @eMerzh committed Mar 22, 2012
Showing with 17 additions and 3 deletions.
  1. +4 −3 apps/backend/modules/loanitem/actions/actions.class.php
  2. +13 −0 lib/model/doctrine/IgsTable.class.php
@@ -157,9 +157,10 @@ public function executeDelmaintenance(sfWebRequest $request)
public function executeGetIgNum(sfWebRequest $request)
{
- /** @Todo: Change for flat_less */
- $spec = Doctrine::getTable('SpecimenSearch')->findOneByPartRef($request->getParameter('id'));
+ $ig = Doctrine::getTable('Igs')->findIgByPartRef($request->getParameter('id'));
$this->getResponse()->setHttpHeader('Content-type', 'application/json');
- return $this->renderText( json_encode(array('ig_num'=>$spec->getIgNum(), 'ig_ref'=>$spec->getIgRef())));
+ if($ig)
+ return $this->renderText( json_encode(array('ig_num'=>$ig->getIgNum(), 'ig_ref'=>$ig->getId())));
+ return $this->renderText( json_encode(array('ig_num'=> 0, 'ig_ref'=>'')));
}
}
@@ -16,4 +16,17 @@ public function fetchByIgNumLimited($ig_num, $limit)
return $q->execute();
}
+ public function findIgByPartRef($id)
+ {
+ $conn_MGR = Doctrine_Manager::connection();
+ $q = Doctrine_Query::create()
+ ->from('Igs i')
+ ->where("exists ( select 1 FROM specimens s2
+ INNER JOIN specimen_individuals i1 ON s2.id = i1.specimen_ref
+ INNER JOIN specimen_parts p3 ON i1.id = p3.specimen_individual_ref
+ WHERE p3.id = ? and s2.ig_ref = i.id
+ )", $id);
+ return $q->fetchOne();
+ }
+
}

0 comments on commit 7ae6536

Please sign in to comment.