home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / companies / do_company_aed.php < prev    next >
Encoding:
PHP Script  |  2003-12-08  |  1.2 KB  |  43 lines

  1. <?php /* COMPANIES $Id: do_company_aed.php,v 1.7 2003/12/08 16:06:55 jcgonz Exp $ */
  2. $del = dPgetParam( $_POST, 'del', 0 );
  3. $obj = new CCompany();
  4. $msg = '';
  5.  
  6. if (!$obj->bind( $_POST )) {
  7.     $AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
  8.     $AppUI->redirect();
  9. }
  10.  
  11. //Assign custom fields to task_custom for them to be saved
  12. $custom_fields = dPgetSysVal("CompanyCustomFields");
  13. $custom_field_data = array();
  14. if ( count($custom_fields) > 0 ){
  15.     foreach ( $custom_fields as $key => $array ) {
  16.         $custom_field_data[$key] = $_POST["custom_$key"];
  17.     }
  18.     $obj->company_custom = serialize($custom_field_data);
  19. }
  20.  
  21. // prepare (and translate) the module name ready for the suffix
  22. $AppUI->setMsg( 'Company' );
  23. if ($del) {
  24.     if (!$obj->canDelete( $msg )) {
  25.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  26.         $AppUI->redirect();
  27.     }
  28.     if (($msg = $obj->delete())) {
  29.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  30.         $AppUI->redirect();
  31.     } else {
  32.         $AppUI->setMsg( 'deleted', UI_MSG_ALERT, true );
  33.         $AppUI->redirect( '', -1 );
  34.     }
  35. } else {
  36.     if (($msg = $obj->store())) {
  37.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  38.     } else {
  39.         $AppUI->setMsg( @$_POST['company_id'] ? 'updated' : 'added', UI_MSG_OK, true );
  40.     }
  41.     $AppUI->redirect();
  42. }
  43. ?>