Commit ded37bb1 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Backup

parent d8d8da83
Loading
Loading
Loading
Loading
Loading
+26 −13
Changes for module/Oscar/src/Oscar/Controller/AdministrationController.php: 26 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -1134,7 +1134,14 @@ class AdministrationController extends AbstractOscarController implements UsePro
        $method = $this->getHttpXMethod();
        $messages = [
            'declarersRelance1' => $this->getOscarConfigurationService()->getDeclarersRelance1(),
            'declarersRelance2' => $this->getOscarConfigurationService()->getDeclarersRelance2()
            'declarersRelanceJour1' => $this->getOscarConfigurationService()->getDeclarersRelanceJour1(),
            'declarersRelance2' => $this->getOscarConfigurationService()->getDeclarersRelance2(),
            'declarersRelanceJour2' => $this->getOscarConfigurationService()->getDeclarersRelanceJour2(),
            /**  **/
            'validatorsRelance1' => $this->getOscarConfigurationService()->getValidatorsRelance1(),
            'validatorsRelanceJour1' => $this->getOscarConfigurationService()->getvalidatorsRelanceJour1(),
            'validatorsRelance2' => $this->getOscarConfigurationService()->getValidatorsRelance2(),
            'validatorsRelanceJour2' => $this->getOscarConfigurationService()->getvalidatorsRelanceJour2(),
        ];

        switch ($method) {
@@ -1142,18 +1149,24 @@ class AdministrationController extends AbstractOscarController implements UsePro
                return $messages;

            case 'POST' :
                switch ($this->params()->fromPost('messageName') ){
                    case 'declarersRelance1' :
                        $value = $this->params()->fromPost('messageValue');
                        $this->getOscarConfigurationService()->setDeclarersRelance1($value);
                        break;
                    case 'declarersRelance2' :
                        $value = $this->params()->fromPost('messageValue');
                        $this->getOscarConfigurationService()->setDeclarersRelance2($value);
                        break;
                    default:
                        return $this->getResponseBadRequest();
                }
                $declarersRelance1 = $this->params()->fromPost('declarersRelance1');
                $declarersRelanceJour1 = (int) $this->params()->fromPost('declarersRelanceJour1');
                $declarersRelance2 = $this->params()->fromPost('declarersRelance2');
                $declarersRelanceJour2 = (int) $this->params()->fromPost('declarersRelanceJour2');
                $validatorsRelance1 = $this->params()->fromPost('validatorsRelance1');
                $validatorsRelanceJour1 = (int) $this->params()->fromPost('validatorsRelanceJour1');
                $validatorsRelance2 = $this->params()->fromPost('validatorsRelance2');
                $validatorsRelanceJour2 = (int) $this->params()->fromPost('validatorsRelanceJour2');

                $this->getOscarConfigurationService()->setDeclarersRelance1($declarersRelance1);
                $this->getOscarConfigurationService()->setDeclarersRelanceJour1($declarersRelanceJour1);
                $this->getOscarConfigurationService()->setDeclarersRelance2($declarersRelance2);
                $this->getOscarConfigurationService()->setDeclarersRelanceJour2($declarersRelanceJour2);
                $this->getOscarConfigurationService()->setValidatorsRelance1($validatorsRelance1);
                $this->getOscarConfigurationService()->setValidatorsRelanceJour1($validatorsRelanceJour1);
                $this->getOscarConfigurationService()->setValidatorsRelance2($validatorsRelance2);
                $this->getOscarConfigurationService()->setValidatorsRelanceJour2($validatorsRelanceJour2);

                return $this->redirect()->toRoute('administration/messages');
                break;
        }
+148 −41
Changes for module/Oscar/src/Oscar/Service/OscarConfigurationService.php: 148 added lines, 41 removed lines.
Original line number Diff line number Diff line
@@ -29,15 +29,18 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface

    const theme = 'theme';

    protected function getConfig(){
    protected function getConfig()
    {
        return $this->getServiceLocator()->get('Config')['oscar'];
    }

    public function getConfigArray(){
    public function getConfigArray()
    {
        return $this->getServiceLocator()->get('Config');
    }

    public function getVersion(){
    public function getVersion()
    {
        return OscarVersion::getBuild();
    }

@@ -46,7 +49,8 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
     * @return array|object
     * @throws OscarException
     */
    public function getConfiguration($key){
    public function getConfiguration($key)
    {
        $config = $this->getConfig();
        if ($key) {
            $paths = explode('.', $key);
@@ -65,7 +69,8 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
     * @param null $defaultValue
     * @return array|null|object
     */
    public function getOptionalConfiguration($key, $defaultValue = null){
    public function getOptionalConfiguration($key, $defaultValue = null)
    {
        $config = $this->getConfig();
        if ($key) {
            $paths = explode('.', $key);
@@ -85,11 +90,13 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
    /**
     * @return string[]
     */
    public function getNumerotationKeys(){
    public function getNumerotationKeys()
    {
        return $this->getEditableConfKey('numerotation', []);
    }

    protected function getYamlConfigPath(){
    protected function getYamlConfigPath()
    {
        $dir = realpath(__DIR__ . '/../../../../../config/autoload/');
        $file = $dir . '/oscar-editable.yml';

@@ -97,14 +104,14 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
            if (!is_writeable($dir)) {
                throw new OscarException("Impossible d'écrire la configuration dans le dossier $dir");
            }
        }
        else if (!is_writeable($file)) {
        } else if (!is_writeable($file)) {
            throw new OscarException("Impossible d'écrire le fichier $file");
        }
        return $file;
    }

    protected function getEditableConfRoot(){
    protected function getEditableConfRoot()
    {
        $path = $this->getYamlConfigPath();
        if (file_exists($path)) {
            $parser = new Parser();
@@ -114,14 +121,16 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
        }
    }

    public function saveEditableConfKey($key, $value){
    public function saveEditableConfKey($key, $value)
    {
        $conf = $this->getEditableConfRoot();
        $conf[$key] = $value;
        $writer = new Dumper();
        file_put_contents($this->getYamlConfigPath(), $writer->dump($conf));
    }

    public function getEditableConfKey($key, $default = null){
    public function getEditableConfKey($key, $default = null)
    {
        $conf = $this->getEditableConfRoot();
        if (array_key_exists($key, $conf)) {
            return $conf[$key];
@@ -130,48 +139,128 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
        }
    }

    public function getOrganizationLeaderRole(){
    public function getOrganizationLeaderRole()
    {
        return $this->getEditableConfKey(self::organization_leader_role, []);
    }

    public function setOrganizationLeaderRole($value){
    public function setOrganizationLeaderRole($value)
    {
        $this->saveEditableConfKey(self::organization_leader_role, $value);
    }

    public function getNumerotationEditable(){
    public function getNumerotationEditable()
    {
        return $this->getEditableConfKey(self::allow_numerotation_custom, false);
    }

    public function setNumerotationEditable( $boolean ){
    public function setNumerotationEditable($boolean)
    {
        $this->saveEditableConfKey(self::allow_numerotation_custom, $boolean);
    }

    public function getValidationPFI(){
    public function getValidationPFI()
    {
        return $this->getConfiguration('validation.pfi');
    }

    public function getTheme(){
    public function getTheme()
    {
        $global = $this->getConfiguration('theme');
        return $this->getEditableConfKey('theme', $global);
    }

    public function getDeclarersRelance1(){
    // --- PARAMETRES de RELANCE

    // DECLARANT
    // RELANCE 1
    public function getDeclarersRelance1()
    {
        return $this->getEditableConfKey('declarersRelance1', '');
    }

    public function setDeclarersRelance1( $value ){
    public function setDeclarersRelance1($value)
    {
        return $this->saveEditableConfKey('declarersRelance1', $value);
    }

    public function getDeclarersRelance2(){
    public function getDeclarersRelanceJour1()
    {
        return $this->getEditableConfKey('declarersRelanceJour1', 1);
    }

    public function setDeclarersRelanceJour1($value)
    {
        return $this->saveEditableConfKey('declarersRelanceJour1', $value);
    }

    // RELANCE 2
    public function getDeclarersRelance2()
    {
        return $this->getEditableConfKey('declarersRelance2', '');
    }

    public function setDeclarersRelance2( $value ){
    public function setDeclarersRelance2($value)
    {
        return $this->saveEditableConfKey('declarersRelance2', $value);
    }

    public function setTheme( $theme ){
    public function getDeclarersRelanceJour2()
    {
        return $this->getEditableConfKey('declarersRelanceJour2', 5);
    }

    public function setDeclarersRelanceJour2($value)
    {
        return $this->saveEditableConfKey('declarersRelanceJour2', $value);
    }

    // VALIDATORS
    // RELANCE 1
    public function getvalidatorsRelance1()
    {
        return $this->getEditableConfKey('validatorsRelance1', '');
    }

    public function setvalidatorsRelance1($value)
    {
        return $this->saveEditableConfKey('validatorsRelance1', $value);
    }

    public function getvalidatorsRelanceJour1()
    {
        return $this->getEditableConfKey('validatorsRelanceJour1', 1);
    }

    public function setvalidatorsRelanceJour1($value)
    {
        return $this->saveEditableConfKey('validatorsRelanceJour1', $value);
    }

    // RELANCE 2
    public function getvalidatorsRelance2()
    {
        return $this->getEditableConfKey('validatorsRelance2', '');
    }

    public function setvalidatorsRelance2($value)
    {
        return $this->saveEditableConfKey('validatorsRelance2', $value);
    }

    public function getvalidatorsRelanceJour2()
    {
        return $this->getEditableConfKey('validatorsRelanceJour2', 5);
    }

    public function setvalidatorsRelanceJour2($value)
    {
        return $this->saveEditableConfKey('validatorsRelanceJour2', $value);
    }


    public function setTheme($theme)
    {
        if (in_array($theme, $this->getConfiguration('themes'))) {
            $this->saveEditableConfKey('theme', $theme);
        } else {
@@ -179,19 +268,23 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
        }
    }

    public function getTimesheetExcel(){
    public function getTimesheetExcel()
    {
        return $this->getEditableConfKey('timesheet_excel', false);
    }

    public function setTimesheetExcel( $bool ){
    public function setTimesheetExcel($bool)
    {
        $this->saveEditableConfKey('timesheet_excel', (boolean)$bool ? true : false);
    }

    public function getTimesheetPreview(){
    public function getTimesheetPreview()
    {
        return $this->getEditableConfKey('timesheet_preview', false);
    }

    public function setTimesheetPreview( $bool ){
    public function setTimesheetPreview($bool)
    {
        $this->saveEditableConfKey('timesheet_preview', (boolean)$bool ? true : false);
    }

@@ -199,7 +292,8 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
     * Retourne l'emplacement où sont stoqués les documents publiques.
     * @return string
     */
    public function getDocumentPublicPath(){
    public function getDocumentPublicPath()
    {
        static $publicdoclocation;
        if ($publicdoclocation == null) {
            $conf = $this->getConfiguration('paths.document_admin_oscar');
@@ -212,60 +306,73 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
    }


    public function getExportSeparator(){
    public function getExportSeparator()
    {
        return $this->getEditableConfKey('export_format', '|');
    }

    public function getExportComputedFields(){
    public function getExportComputedFields()
    {
        return $this->getConfiguration('export.computedFields', []);
    }

    public function getEstimatedSpentActivityTemplate(){
    public function getEstimatedSpentActivityTemplate()
    {
        return $this->getConfiguration('estimated_spent_activity_template');
    }

    public function getGearmanHost(){
    public function getGearmanHost()
    {
        return $this->getConfiguration('gearman-job-server-host');
    }

    public function setExportSeparator( $string ){
    public function setExportSeparator($string)
    {
        $this->saveEditableConfKey('export_format', $string);
    }

    public function getExportDateFormat(){
    public function getExportDateFormat()
    {
        return $this->getEditableConfKey('export_dateformat', 'y-m-d');
    }

    public function setExportDateFormat( $string ){
    public function setExportDateFormat($string)
    {
        $this->saveEditableConfKey('export_dateformat', $string);
    }

    public function getSpentAccountFilter(){
    public function getSpentAccountFilter()
    {
        return $this->getEditableConfKey(self::spents_account_filter, []);
    }

    public function setSpentAccountFilter( $stringArray ){
    public function setSpentAccountFilter($stringArray)
    {
        $extract = new DataStringArray();
        $data = $extract->extract($stringArray);
        $this->saveEditableConfKey(self::spents_account_filter, $data);
    }

    public function getActivityRequestLimit(){
    public function getActivityRequestLimit()
    {
        return $this->getEditableConfKey(self::activity_request_limit, 5);
    }

    public function setActivityRequestLimit( int $value ){
    public function setActivityRequestLimit(int $value)
    {
        $this->saveEditableConfKey(self::activity_request_limit, $value);
    }

    public function getMasses(){
    public function getMasses()
    {
        return $this->getConfiguration('spenttypeannexes');
    }

    /**
     * @return bool
     */
    public function getAutoUpdateSpent(){
    public function getAutoUpdateSpent()
    {
        return $this->getOptionalConfiguration("autorefreshspents", false);
    }
}
 No newline at end of file
+39 −15
Changes for module/Oscar/view/oscar/administration/messages.phtml: 39 added lines, 15 removed lines.
Original line number Diff line number Diff line
<div class="container">
    <form action="" method="post">
        <h1>Messages de relance</h1>
        <div class="row">
            <div class="col-md-4">
            <form action="" method="post">
                <h3><i class="icon-calendar"></i> Déclarants, Première relance</h3>
                <input type="hidden" name="messageName" value="declarersRelance1" />
                <textarea name="messageValue" id="" cols="30" rows="10" class="form-control"><?= $declarersRelance1 ?></textarea>
                <button type="submit" class="btn btn-primary">
                    Enregistrer
                </button>
            </form>
                <h3><i class="icon-calendar"></i> Déclarants, première relance</h3>
                <p>
                    Envoyée à <strong>J+</strong>
                    <input type="number" name="declarersRelanceJour1" value="<?= $declarersRelanceJour1 ?>"/>
                </p>
                <textarea name="declarersRelance1" id="" cols="30" rows="10"
                          class="form-control"><?= $declarersRelance1 ?></textarea>
            </div>
            <div class="col-md-4">
            <form action="" method="post">
                <h3><i class="icon-calendar"></i> Déclarant, Deuxième relance</h3>
                <input type="hidden" name="messageName" value="declarersRelance2" />
                <textarea name="messageValue" id="" cols="30" rows="10" class="form-control"><?= $declarersRelance2 ?></textarea>
                <h3><i class="icon-calendar"></i> Déclarant, deuxième relance</h3>
                <p>
                    Envoyée à <strong>J+</strong>
                    <input type="number" name="declarersRelanceJour2" value="<?= $declarersRelanceJour2 ?>"/>
                </p>
                <textarea name="declarersRelance2" id="" cols="30" rows="10"
                          class="form-control"><?= $declarersRelance2 ?></textarea>
            </div>
        </div>

        <div class="row">
            <div class="col-md-4">
                <h3><i class="icon-calendar"></i> Validateur scientifique, première relance</h3>
                <p>
                    Envoyée à <strong>J+</strong>
                    <input type="number" name="validatorsRelanceJour1" value="<?= $validatorsRelanceJour1 ?>"/>
                </p>
                <textarea name="validatorsRelance1" id="" cols="30" rows="10"
                          class="form-control"><?= $validatorsRelance1 ?></textarea>
            </div>
            <div class="col-md-4">
                <h3><i class="icon-calendar"></i> Validateur scientifique, Deuxième relance</h3>
                <p>
                    Envoyée à <strong>J+</strong>
                    <input type="number" name="validatorsRelanceJour2" value="<?= $validatorsRelanceJour2 ?>"/>
                </p>
                <textarea name="validatorsRelance2" id="" cols="30" rows="10"
                          class="form-control"><?= $validatorsRelance2 ?></textarea>
            </div>
        </div>

        <button type="submit" class="btn btn-primary">
            Enregistrer
        </button>
    </form>
</div>
 No newline at end of file
    </div>

</div>
 No newline at end of file