entreprise = new stdClass(); $this->dateFunction = new WDate(); $this->view->headLink()->appendStylesheet('/themes/default/styles/finance.css', 'all'); require_once ('Scores/WsScores.php'); $this->ws = new WsScores(); $entreprise = new SessionEntreprise($this->getRequest()->getParam('siret'), $this->getRequest()->getParam('id')); $this->view->assign('dateFunction', $this->dateFunction); $this->entreprise->nom = $entreprise->getRaisonSociale(); } public function syntheseAction() { $syntheseReference = array(); $tabRatio = array( 'r5' => array('CHIFFRE D\'AFFAIRES', 1000, ' K€', 'r6'), 'r7' => array('RESULTAT COURANT AVANT IMPOTS', 1000, ' K€', 'r8'), 'r10' => array('RESULTAT NET', 1000, ' K€', 'r11'), 'r18' => array('FONDS PROPRES', 1000, ' K€', 'r19'), 'r22' => array('TOTAL BILAN', 1000,' K€', 'r23'), 'r231' => array('FONDS DE ROULEMENT', 1000, ' K€', 'r235'), 'r232' => array('BESOIN EN FONDS DE ROULEMENT', 1000, ' K€', 'r236'), 'r249' => array('TRESORERIE', 1000, ' K€','r254'), 'r24' => array('EFFECTIF', 1, ' Pers.', 'r24') ); $this->view->assign('tabRatio', $tabRatio); $results = $this->ws->getRatios(substr($this->getRequest()->getParam('siret'), 0, 9), 'synthese'); $this->view->assign('results', $results); $this->view->assign('siret', $this->getRequest()->getParam('siret')); $this->view->assign('bilanInfo', $results->RatiosInfos->item); // echo '
'; print_r($results);exit;
	    echo '
';$a = new Synthese($results->BilansInfos, $results->RatiosInfos);exit;
	    foreach ($results->BilansInfos as $items)
	    {
	        foreach ($items as $row) {
	            foreach ($row as $champ => $valeur) {
	                foreach($row->RatiosEntrepEvol as $champRatiosEntrepEvol => $RatiosEntrepEvol) {
            	        if ($champ == 'dateCloture') {
            	            $date = $valeur;
            	            if (!array_key_exists($date, $syntheseReference))
            	                $syntheseReference[$date] = array();
            	        }
            	        if($champ == 'duree')
            	            $syntheseReference[$date][$champ] = $valeur;
            	        if ($champ == 'typeBilan') {
        	                $type = $valeur;
        	                $syntheseReference[$date][$type] = array();
            	        }
            	        if($champ == 'RatiosEntrep') {
            	            $rationEntrep = $champ;
            	            foreach($tabRatio as $chm => $element) {
            	                foreach($valeur->item as $itemElement) {
                	                if ($chm == $itemElement->id) {
                	                    $var = $syntheseReference[$date][$type][$rationEntrep][] = new stdClass();
                	                    $var->val = number_format($itemElement->val/$element[1], 0, '', ' ') . ' ' .$element[2];
                	                    $var->label = $element[0];
                	                    foreach ($RatiosEntrepEvol as $itemRatiosEntrepEvol) {
                    	                    if($itemRatiosEntrepEvol->id == $element[3]) {
                    	                        $var->evol = $itemRatiosEntrepEvol->val;
                    	                        (($itemRatiosEntrepEvol->val != 'NS') ? $var->evol .= ' %' : false);
                    	                    }
                	                    }
                	                }
            	                }
            	            }
            	        }
	                }
	            }
	        }
	    }
	    
	    arsort($syntheseReference);
	    $i = count($syntheseReference);
	    $syntheseReference2 = array_slice($syntheseReference, $i-3, $i, true);
	    $this->view->assign('synthese', $syntheseReference2);
	}
	
	public function bilansAction()
	{
	    
	}

	public function ratiosAction()
	{
	    echo '
';
	    //print_r($this->ws->getRatios(substr($this->getRequest()->getParam('siret'), 0, 9), 'ratios'));
	    echo '
'; } private function selectInUnit($tab, $unite) { foreach($tab as $champ => $val) { if($val == $unite) return ($champ); } return (false); } public function liasseAction() { $this->view->headScript() ->appendFile('/themes/default/scripts/finance.js', 'text/javascript'); $ancres = array('C' => array('actif', 'passif', 'compteDeResultat'), 'N' => array('actif', 'passif', 'compteDeResultat', 'immobilisations', 'amortissements', 'provisions', 'creancesDettes', 'affectation'), 'A' => array('actif', 'passif', 'compteDeResultat'), 'B' => array('actif', 'passif', 'compteDeResultat') ); /** La liste des type de bilan existant **/ $liste = array ('N' => array(), 'S' => array(), 'C' => array(), 'B' => array(), 'A' => array()); /** Le nom des type pour le select */ $type = array ('A' => 'Assurance', 'B' => 'Banque', 'C' => 'Consolidé', 'N' => ''); /** Liste des unités que l'ont proposent **/ $unit = array ('€' => 1, 'K€' => 1000, 'M€' => 1000000); $liasse = array (); $date = $this->getRequest()->getParam('date'); $siret = $this->getRequest()->getParam('siret'); $id = $this->getRequest()->getParam('id'); $listBilan = $this->ws->getListeBilans(substr($this->getRequest()->getParam('siret'), 0, 9)); $unite = $this->getRequest()->getParam('unit'); foreach ($listBilan->result->item as $item) $liste[$item->typeBilan][] = $item->dateExercice; /** ont transforme les bilan de type S en N **/ $NandS = array_merge($liste['N'], $liste['S']); $liste['N'] = $NandS;unset($liste['S']); if (!empty($date)) { $dateAndType = explode(':', $date); $liasses = $this->ws->getBilan(substr($this->getRequest()->getParam('siret'), 0, 9), $dateAndType[0], $dateAndType[1], true); $this->view->assign('dateCloture', $liasses->DATE_CLOTURE); $this->view->assign('dateCloturePre', $liasses->DATE_CLOTURE_PRE); $this->view->assign('dureesMois', $liasses->DUREE_MOIS); $this->view->assign('dureesMoisPre', $liasses->DUREE_MOIS_PRE); foreach ($liasses->POSTES->item as $element) { $liasse[$element->id] = number_format(($element->val > 0)?$element->val / $unite:$element->val, 0, '', ' ') .' '.self::selectInUnit($unit, $unite); } $t = explode(':', $date); $this->view->assign('champType', $t[1]); $this->view->assign('liasse', $liasse); } /** Partie vue **/ $this->view->assign('ancres', $ancres); $this->view->assign('typeFeuille', $typeFeuille); $this->view->assign('liste', $liste); $this->view->assign('nomSociete', $this->entreprise->nom); $this->view->assign('siret', $siret); $this->view->assign('id', $id); $this->view->assign('type', $type); $this->view->assign('unit', $unit); } public function bourseAction() { } public function banqueAction() { } }