--- /dev/null
+<?php
+
+class ContractsController extends ApplicationController {
+
+ /** @var PdoContractManager */
+ private $pdoContractManager;
+
+ private function getPdoContractManager(){
+ if (! $this->pdoContractManager){
+ $this->pdoContractManager = new PdoContractManager();
+ }
+ return $this->pdoContractManager;
+ }
+
+ /**
+ * @api {get} /index.php?action=contracts_nb Récupération du nombre de contrats
+ * @apiName Nb contrat
+ * @apiGroup Contracts
+ * @apiVersion 1.0.0
+ *
+ * @apiSuccessExample {json} Success-Reponse:
+ * {"retour":"OK","message":"","result":"646"}
+ */
+ public function nbAction(){
+ return $this->getPdoContractManager()->getNbContrat();
+ }
+
+ /**
+ * @api {get} /index.php?action=contracts_list Récupère la liste des contrats
+ * @apiName customers
+ * @apiGroup Contracts
+ * @apiVersion 1.0.0
+ * @apiParam {Number} limit Nombre d'élements à récupérer
+ * @apiParam {Number} offset Numéro du premier élement à récupérer
+ *
+ * @apiSuccessExample {json} Success-Reponse:
+ {"retour":"OK","message":"","result":[{"id":"317","number":" XYZT","state":"^signe^","start_date":"2013-09-01","end_date":"2014-12-31"},{"id":"66","number":"BAR","state":"^signe^","start_date":"2011-01-01","end_date":"2016-05-31"}]}
+ *
+ */
+ public function listAction(){
+ $offset = $this->getOffsetParameter();
+ $limit = $this->getLimitParameter();
+ $contracts_list = $this->getPdoContractManager()->getContractsForOutput($offset,$limit);
+ return $contracts_list;
+ }
+
+ /**
+ * @api {get} /index.php?action=contracts_listByCustomer Récupère la liste des contrats par client
+ * @apiGroup Contracts
+ * @apiVersion 1.0.0
+ * @apiParam {Number} ap_id Identifiant AP du client
+ *
+ * @apiSuccessExample {json} Success-Reponse:
+ *{"retour":"OK","message":"","result":[{"number":" IP\/IIOPPO\/2013","state":"^signe^","start_date":"2013-09-01","end_date":"2014-12-31"},{"number":"SL\/UIZP\/2015","state":"^signe^","start_date":"2015-03-01","end_date":"2015-12-31"}]}
+ */
+ public function listByCustomerAction(){
+ $ap_id = $this->getParameters()->get('ap_id');
+ $pdoCustomersManager = new PdoCustomerManager();
+ $customer = $pdoCustomersManager->getCustomerByAPId($ap_id);
+ if (! $customer){
+ throw new Exception("ap_id ({$ap_id}) inconnu sur ce serveur.");
+ }
+ return $this->getPdoContractManager()->getByCustomerId($customer->id);
+ }
+
+}
\ No newline at end of file