Commit 9d108f04 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

UP : Ajout du champ 'Note financière' aux champs exportables

parent 5b05c4d1
Loading
Loading
Loading
Loading
+212 −161
Original line number Diff line number Diff line
@@ -124,8 +124,6 @@ class Activity implements ResourceInterface
    }




    /**
     * @ORM\Column(type="string", nullable=true)
     */
@@ -414,11 +412,13 @@ class Activity implements ResourceInterface
        return $this->totalSpent;
    }

    public function getPercentSpent(){
    public function getPercentSpent()
    {
        return 100 / $this->getAmount() * abs($this->getTotalSpent());
    }

    public function getRemainder(){
    public function getRemainder()
    {
        return $this->getAmount() - abs($this->getTotalSpent());
    }

@@ -506,13 +506,13 @@ class Activity implements ResourceInterface
    }



    /**
     * Retourne l'acronyme du projet si disponible.
     *
     * @return mixed|null
     */
    public function getAcronym(){
    public function getAcronym()
    {
        if ($this->getProject()) {
            return $this->getProject()->getAcronym();
        }
@@ -524,8 +524,9 @@ class Activity implements ResourceInterface
     */
    public function getNumbers()
    {
        if( $this->numbers == null )
        if ($this->numbers == null) {
            $this->numbers = [];
        }
        return $this->numbers;
    }

@@ -544,7 +545,8 @@ class Activity implements ResourceInterface
     * @param $value
     * @return $this
     */
    public function addNumber( $key, $value ){
    public function addNumber($key, $value)
    {
        $this->numbers[$key] = $value;
        return $this;
    }
@@ -553,7 +555,8 @@ class Activity implements ResourceInterface
     * @param $key
     * @return $this
     */
    public function removeNumber( $key ){
    public function removeNumber($key)
    {
        if (key_exists($key, $this->numbers)) {
            unset($this->numbers[$key]);
        }
@@ -564,7 +567,8 @@ class Activity implements ResourceInterface
     * @param $key
     * @return null
     */
    public function getNumber( $key ){
    public function getNumber($key)
    {
        if ($this->numbers && key_exists($key, $this->numbers)) {
            return $this->numbers[$key];
        }
@@ -951,7 +955,8 @@ class Activity implements ResourceInterface
        return $this->label;
    }

    public function getFullLabel(){
    public function getFullLabel()
    {
        return sprintf('[%s] %s', $this->getAcronym(), $this->getLabel());
    }

@@ -1009,7 +1014,8 @@ class Activity implements ResourceInterface
        return $this->duration;
    }

    public function getCalculatedDuration(){
    public function getCalculatedDuration()
    {
        if ($this->getDateStart() && $this->getDateEnd()) {
            return ceil(($this->getDateEnd()->getTimestamp() - $this->getDateStart()->getTimestamp()) / (60 * 60 * 24));
        }
@@ -1098,7 +1104,8 @@ class Activity implements ResourceInterface
     *
     * @return array
     */
    public function getPredictedPeriods(){
    public function getPredictedPeriods()
    {
        $out = [
            'warnings' => null,
            'periods' => [],
@@ -1247,7 +1254,9 @@ class Activity implements ResourceInterface
        $today = new \DateTime();
        /** @var ActivityPerson $member */
        foreach ($this->getPersons() as $member) {
            if(!$member->getPerson()){continue;}
            if (!$member->getPerson()) {
                continue;
            }
            if ($member->getPerson()->getId() === $person->getId()) {
                // Date de début non-nulle et suppérieur à ajourd'hui
                if ($member->getDateStart() !== null && $member->getDateStart() > $today) {
@@ -1271,8 +1280,8 @@ class Activity implements ResourceInterface
     *
     * @return array
     */
    public function getPersonPrincipalActive(){

    public function getPersonPrincipalActive()
    {
        $persons = [];

        /** @var ActivityPerson $member */
@@ -1346,7 +1355,8 @@ class Activity implements ResourceInterface
        return $persons;
    }

    public function getPersonJson(){
    public function getPersonJson()
    {
        $json = [];
        /** @var ActivityPerson $activityPerson */
        foreach ($this->getPersonsDeep() as $activityPerson) {
@@ -1417,7 +1427,9 @@ class Activity implements ResourceInterface
        }

        if (!isset($sluged[$this->getActivityType()->getNature()])) {
            $sluged[$this->getActivityType()->getNature()] = 'icon-acttype-' . $slugify->slugify($this->getActivityType()->getNatureStr());
            $sluged[$this->getActivityType()->getNature()] = 'icon-acttype-' . $slugify->slugify(
                    $this->getActivityType()->getNatureStr()
                );
        }

        return $sluged[$this->getActivityType()->getNature()];
@@ -1626,8 +1638,12 @@ class Activity implements ResourceInterface

    public function __toString()
    {
        return sprintf("[%s%s] %s", $this->getOscarNum(),
            $this->getCodeEOTP() ? ' ~ ' . $this->getCodeEOTP() : '', $this->getLabel());
        return sprintf(
            "[%s%s] %s",
            $this->getOscarNum(),
            $this->getCodeEOTP() ? ' ~ ' . $this->getCodeEOTP() : '',
            $this->getLabel()
        );
    }

    public function log()
@@ -1672,7 +1688,8 @@ class Activity implements ResourceInterface
        return $inCharge;
    }

    public function hasMilestoneAt( DateType $type, \DateTime $date){
    public function hasMilestoneAt(DateType $type, \DateTime $date)
    {
        /** @var ActivityDate $milestone */
        foreach ($this->getMilestones() as $milestone) {
            if ($milestone->getDateStart() == $date && $milestone->getType() == $type) {
@@ -1682,10 +1699,12 @@ class Activity implements ResourceInterface
        return false;
    }

    public function hasPaymentAt( $amount, $datePayment, $datePredicted ){
    public function hasPaymentAt($amount, $datePayment, $datePredicted)
    {
        /** @var ActivityPayment $payment */
        foreach ($this->getPayments() as $payment) {
            if( $payment->getDatePayment() == $datePayment  && $payment->getAmount() == $amount && $payment->getDatePredicted() == $datePredicted){
            if ($payment->getDatePayment() == $datePayment && $payment->getAmount(
                ) == $amount && $payment->getDatePredicted() == $datePredicted) {
                return true;
            }
        }
@@ -1756,7 +1775,6 @@ class Activity implements ResourceInterface
     */
    public function getCorpus()
    {

    }

    private $_cachedPercentDone = null;
@@ -1765,7 +1783,8 @@ class Activity implements ResourceInterface

    private $_cachedTodoDone = null;

    protected function getTodoDone(){
    protected function getTodoDone()
    {
        if ($this->_cachedTodoDone === null) {
            $todo = 0.0;
            $tovalidate = 0.0;
@@ -1804,14 +1823,17 @@ class Activity implements ResourceInterface
    {
        return $this->getTodoDone()['percent'];
    }

    public function getDone()
    {
        return $this->getTodoDone()['done'];
    }

    public function getTodo()
    {
        return $this->getTodoDone()['todo'];
    }

    public function getTovalidate()
    {
        return $this->getTodoDone()['tovalidate'];
@@ -1823,7 +1845,8 @@ class Activity implements ResourceInterface
     * @param string $format
     * @return string
     */
    public function getDateStartStr( $format = 'Y-m-d' ){
    public function getDateStartStr($format = 'Y-m-d')
    {
        if ($this->getDateStart()) {
            return $this->getDateStart()->format($format);
        } else {
@@ -1837,7 +1860,8 @@ class Activity implements ResourceInterface
     * @param string $format
     * @return string
     */
    public function getDateEndStr( $format = 'Y-m-d' ){
    public function getDateEndStr($format = 'Y-m-d')
    {
        if ($this->getDateEnd()) {
            return $this->getDateEnd()->format($format);
        } else {
@@ -1848,8 +1872,8 @@ class Activity implements ResourceInterface
    /**
     * Retourne les données préparées pour le génération des documents
     */
    public function documentDatas(){

    public function documentDatas()
    {
        //
        $datas = [
            'id' => $this->getId(),
@@ -1858,7 +1882,11 @@ class Activity implements ResourceInterface
            'pfi' => $this->getCodeEOTP(),
            'oscar' => $this->getOscarNum(),
            'montant' => number_format(
                (double)$this->getAmount(), 2, ',', ' ') . $this->getCurrency()->getSymbol(),
                    (double)$this->getAmount(),
                    2,
                    ',',
                    ' '
                ) . $this->getCurrency()->getSymbol(),
            'annee-debut' => $this->getDateStartStr('Y'),
            'annee-fin' => $this->getDateEndStr('Y'),
            'debut' => $this->getDateStartStr('d/m/Y'),
@@ -1938,7 +1966,6 @@ class Activity implements ResourceInterface

        /** @var ActivityPayment $payment */
        foreach ($this->getPayments() as $payment) {

            $amount = number_format($payment->getAmount(), 2) . ' ' . $this->getCurrency()->getSymbol();

            if ($payment->getDatePayment()) {
@@ -1965,7 +1992,6 @@ class Activity implements ResourceInterface


        return $datas;

    }

    public function csv($dateFormat = 'Y-m-d')
@@ -1993,6 +2019,7 @@ class Activity implements ResourceInterface
            'Frais de gestion' => $this->getFraisDeGestion(),
            'Frais de gestion (part hébergeur)' => $this->getFraisDeGestionPartHebergeur(),
            'incidence financière' => $this->getIncidenceFinanciere(),
            'Note financière' => $this->getNoteFinanciere(),
            'Disciplines' => $this->getDisciplines() ? implode(", ", $this->getDisciplinesArray()) : ""
        );
    }
@@ -2016,12 +2043,14 @@ class Activity implements ResourceInterface
            'Fin',
            'Date de signature',
            'versement effectué',
            'versement effectué',
            'versement prévu',
            'écart de paiement',
            'justificatif écart de paiement',
            'Frais de gestion',
            'Frais de gestion (part hébergeur)',
            'incidence financière',
            'Note financière',
            'Disciplines'
        );
    }
@@ -2049,6 +2078,7 @@ class Activity implements ResourceInterface
    }

    private $totalEcartPaiement;

    public function getEcartPaiement()
    {
        if ($this->totalEcartPaiement === null) {
@@ -2065,6 +2095,7 @@ class Activity implements ResourceInterface
    }

    private $justificatifEcartPaiement;

    public function getJustificatifEcartPaiement()
    {
        if ($this->justificatifEcartPaiement === null) {
@@ -2087,11 +2118,11 @@ class Activity implements ResourceInterface


    /**
    'écart de paiement' => $this->getEcartPaiement(),
    'justificatif écart de paiement' => $this->getJustificatifEcartPaiement(),
    'Frais de gestion' => $this->getFraisDeGestion(),
    'Frais de gestion (part hébergeur)' => $this->getFraisDeGestionPartHebergeur(),
    'incidence financière' => $this->getIncidenceFinanciere(),
     * 'écart de paiement' => $this->getEcartPaiement(),
     * 'justificatif écart de paiement' => $this->getJustificatifEcartPaiement(),
     * 'Frais de gestion' => $this->getFraisDeGestion(),
     * 'Frais de gestion (part hébergeur)' => $this->getFraisDeGestionPartHebergeur(),
     * 'incidence financière' => $this->getIncidenceFinanciere(),
     */

    private $totalPaymentProvided;
@@ -2146,12 +2177,22 @@ class Activity implements ResourceInterface
            }
            $out['organizations'] = [];
            foreach ($this->getOrganizations() as $organizationActivity) {
                $out['organizations'][] = sprintf('%s (%s)', $organizationActivity->getOrganization()->__toString(), $organizationActivity->getRoleObj());
                $out['organizations'][] = sprintf(
                    '%s (%s)',
                    $organizationActivity->getOrganization()->__toString(),
                    $organizationActivity->getRoleObj()
                );
            }
            $out['payments'] = [];
            /** @var ActivityPayment $payment */
            foreach ($this->getPayments() as $payment) {
                $out['payments'][] = sprintf('%s (%s)', $payment->getAmount(), $payment->getDatePayment() ? $payment->getDatePayment()->format('Ymd') : 'nop');
                $out['payments'][] = sprintf(
                    '%s (%s)',
                    $payment->getAmount(),
                    $payment->getDatePayment() ? $payment->getDatePayment()->format(
                        'Ymd'
                    ) : 'nop'
                );
            }
        }

@@ -2177,12 +2218,14 @@ class Activity implements ResourceInterface
    /// COMPUTED
    ///

    public function hasDeclarant( $person ){
    public function hasDeclarant($person)
    {
        if (!$person) {
            return false;
        }
        if( $person instanceof ActivityPerson || $person instanceof ProjectMember )
        if ($person instanceof ActivityPerson || $person instanceof ProjectMember) {
            $person = $person->getPerson();
        }

        /** @var WorkPackage $wp */
        foreach ($this->getWorkPackages() as $wp) {
@@ -2201,7 +2244,8 @@ class Activity implements ResourceInterface
     *
     * @return bool
     */
    public function hasDeclarers(){
    public function hasDeclarers()
    {
        /** @var WorkPackage $wp */
        foreach ($this->getWorkPackages() as $wp) {
            foreach ($wp->getPersons() as $p) {
@@ -2214,7 +2258,8 @@ class Activity implements ResourceInterface
    /**
     * @return Person[]
     */
    public function getDeclarers(){
    public function getDeclarers()
    {
        $persons = [];

        /** @var WorkPackage $workPackage */
@@ -2230,7 +2275,8 @@ class Activity implements ResourceInterface
        return $persons;
    }

    public function getTimesheets(){
    public function getTimesheets()
    {
        $timesheets = [];
        /** @var WorkPackage $workPackage */
        foreach ($this->getWorkPackages() as $workPackage) {
@@ -2242,7 +2288,8 @@ class Activity implements ResourceInterface
        return $timesheets;
    }

    public function hasTimesheetsUpForValidation(){
    public function hasTimesheetsUpForValidation()
    {
        /** @var TimeSheet $timesheet */
        foreach ($this->getTimesheets() as $timesheet) {
            if (true === $timesheet->isWaitingValidation()) {
@@ -2252,7 +2299,8 @@ class Activity implements ResourceInterface
        return false;
    }

    public function hasTimesheetsUpForValidationAdmin(){
    public function hasTimesheetsUpForValidationAdmin()
    {
        /** @var TimeSheet $timesheet */
        foreach ($this->getTimesheets() as $timesheet) {
            if (true === $timesheet->isWaitingValidationAdmin()) {
@@ -2262,7 +2310,8 @@ class Activity implements ResourceInterface
        return false;
    }

    public function hasTimesheetsUpForValidationSci(){
    public function hasTimesheetsUpForValidationSci()
    {
        /** @var TimeSheet $timesheet */
        foreach ($this->getTimesheets() as $timesheet) {
            if (true === $timesheet->isWaitingValidationSci()) {
@@ -2276,12 +2325,14 @@ class Activity implements ResourceInterface
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    private $tmpOrganizationsWithRoleForm = [];

    public function setOrganizationsWithRoleForm( $formName, $formValue ){
    public function setOrganizationsWithRoleForm($formName, $formValue)
    {
        var_dump($formName);
        var_dump($formValue);
    }

    public function getOrganizationsWithRoleForm( $formName ){
    public function getOrganizationsWithRoleForm($formName)
    {
        if (array_key_exists($formName)) {
            return $this->tmpOrganizationsWithRoleForm[$formName];
        } else {