Results 1 to 5 of 5

Thread: Crezione Automatica Compiti Progetto

  1. #1
    ff76 is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    96

    Default Crezione Automatica Compiti Progetto

    Buongiorno a tutti,

    io avrei la necessità di creare dei Compiti di Progetto in automatico..

    Dato che questi Compiti sono sempre gli stessi, io vorrei che ogni volta che creo il Progetto, vengano automaticamente inseriti i miei 4 Compiti di Progetto..

    Come posso fare?

    Io ho visto che c'è un file Save.php nel modulo Progetti e pertanto pensavo di inserire all'interno di questo file le mie 4 insert...

    Il problema che mi sono posto è il seguente...

    Sugar ogni qualvosta inseriamo un Nuovo Progetto o Compito genera automaticamente un id...

    Come posso sapere l'id che devo mettere nella mia insert? C'è una funzione che lo genera e se si, qual'è ?


    Ho estremamente bisogno di un vostro aiuto...

    Grazie..

  2. #2
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Crezione Automatica Compiti Progetto

    Che versione usi?
    Logic hooks di solito, dovrebbero esserci degli esempi sul forum.
    What do you think the cookie monster eats ?

  3. #3
    ff76 is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    96

    Default Re: Crezione Automatica Compiti Progetto

    uso la versione 4.5.1

  4. #4
    ff76 is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    96

    Default Re: Crezione Automatica Compiti Progetto

    Come mi èstato detto in un altro forum ho creato i seguenti file:

    1) custom/modules/Project/logic_hooks.php


    PHP Code:
    <?php 
    $hook_version 
    1
    $hook_array = Array(); 

    $hook_array['before_save'] = Array(); 
    $hook_array['before_save'][] = Array(1'createProjectTasks''custom/modules/Project/ProjectLogicHook.php','ProjectLogicHook''createProjectTasks'); 
    ?>
    2) custom/modules/Project/ProjectLogicHook.php

    PHP Code:
    <?php 
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 

    class 
    ProjectLogicHook 
        function 
    createProjectTasks(&$focus$event$arguments) { 
            
    $project = new Project(); 
            
    $project->retrieve($focus->id); 

            if(
    $project->name == '') { 
                require_once(
    'modules/ProjectTask/ProjectTask.php'); 
                 
                
    $project_task_config $this->getProjectTaskConfig(); 
                 
                foreach(
    $project_task_config as $config) { 
                    
    $pt = new ProjectTask(); 
                    
    $pt->project_id $focus->id
                     
                    foreach(
    $config as $field => $value) { 
                        
    $pt->$field $value
                    } 
                     
                    
    $pt->save(); 
                } 
            } 
        } 
         
        function 
    getProjectTaskConfig() { 
            
    $project_task_config = array( 
                array( 
                    
    'name' => 'Analisi'
                    
    'project_task_id' => 1
                    
    'duration' => 1
                    
    'duration_unit' => 'Days'
                ), 
                array( 
                    
    'name' => 'Test'
                    
    'project_task_id' => 2
                    
    'duration' => 5
                    
    'duration_unit' => 'Hours'
                ), 
            ); 
        } 

    ?>
    Quando creo un progetto non vengono creati in automatico i Compiti... Come mai ?????
    Last edited by ff76; 2008-10-29 at 01:38 PM.

  5. #5
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Crezione Automatica Compiti Progetto

    Quote Originally Posted by ff76
    uso la versione 4.5.1
    Ok, alzo le mani, è una versione che non conosco.
    What do you think the cookie monster eats ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •