![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: addedit.php 178 2008-07-17 15:03:35Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/companies/addedit.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 $company_id = intval(w2PgetParam($_GET, 'company_id', 0)); 7 8 // check permissions for this company 9 $perms = &$AppUI->acl(); 10 // If the company exists we need edit permission, 11 // If it is a new company we need add permission on the module. 12 if ($company_id) { 13 $canEdit = $perms->checkModuleItem('companies', 'edit', $company_id); 14 } else { 15 $canEdit = $perms->checkModule('companies', 'add'); 16 } 17 18 if (!$canEdit) { 19 $AppUI->redirect('m=public&a=access_denied'); 20 } 21 22 // load the company types 23 $types = w2PgetSysVal('CompanyType'); 24 $countries = array('' => $AppUI->_('(Select a Country)')) + w2PgetSysVal('GlobalCountries'); 25 26 // load the record data 27 $q = new DBQuery; 28 $q->addTable('companies'); 29 $q->addQuery('companies.*'); 30 $q->addQuery('con.contact_first_name'); 31 $q->addQuery('con.contact_last_name'); 32 $q->leftJoin('users', 'u', 'u.user_id = companies.company_owner'); 33 $q->leftJoin('contacts', 'con', 'u.user_contact = con.contact_id'); 34 $q->addWhere('companies.company_id = ' . (int)$company_id); 35 $obj = null; 36 $q->loadObject($obj); 37 $q->clear(); 38 39 if (!$obj && $company_id > 0) { 40 // $AppUI->setMsg( ' $qid =& $q->exec(); Company' ); // What is this for? 41 $AppUI->setMsg('invalidID', UI_MSG_ERROR, true); 42 $AppUI->redirect(); 43 } 44 45 // collect all the users for the company owner list 46 $q = new DBQuery; 47 $q->addTable('users', 'u'); 48 $q->addTable('contacts', 'con'); 49 $q->addQuery('user_id'); 50 $q->addQuery('CONCAT(contact_first_name, \' \', contact_last_name)'); 51 $q->addOrder('contact_last_name'); 52 $q->addWhere('u.user_contact = con.contact_id'); 53 $owners = $q->loadHashList(); 54 55 // setup the title block 56 $ttl = $company_id > 0 ? 'Edit Company' : 'Add Company'; 57 $titleBlock = new CTitleBlock($ttl, 'handshake.png', $m, $m . '.' . $a); 58 $titleBlock->addCrumb('?m=companies', 'companies list'); 59 if ($company_id != 0) { 60 $titleBlock->addCrumb('?m=companies&a=view&company_id=' . $company_id, 'view this company'); 61 } 62 $titleBlock->show(); 63 ?> 64 65 <script language="javascript"> 66 function submitIt() { 67 var form = document.changeclient; 68 if (form.company_name.value.length < 3) { 69 alert( "<?php echo $AppUI->_('companyValidName', UI_OUTPUT_JS); ?>" ); 70 form.company_name.focus(); 71 } else { 72 form.submit(); 73 } 74 } 75 76 function testURL( x ) { 77 var test = 'document.changeclient.company_primary_url.value'; 78 test = eval(test); 79 if (test.length > 6) { 80 newwin = window.open( 'http://' + test, 'newwin', '' ); 81 } 82 } 83 </script> 84 85 <table cellspacing="1" cellpadding="1" border="0" width='100%' class="std"> 86 <tr> 87 <td> 88 <table> 89 <form name="changeclient" action="?m=companies" method="post"> 90 <input type="hidden" name="dosql" value="do_company_aed" /> 91 <input type="hidden" name="company_id" value="<?php echo $company_id; ?>" /> 92 <tr> 93 <td align="right"><?php echo $AppUI->_('Company Name'); ?>:</td> 94 <td> 95 <input type="text" class="text" name="company_name" value="<?php echo w2PformSafe($obj->company_name); ?>" size="50" maxlength="255" /> (<?php echo $AppUI->_('required'); ?>) 96 </td> 97 </tr> 98 <tr> 99 <td align="right"><?php echo $AppUI->_('Email'); ?>:</td> 100 <td> 101 <input type="text" class="text" name="company_email" value="<?php echo w2PformSafe($obj->company_email); ?>" size="30" maxlength="255" /> 102 </td> 103 </tr> 104 <tr> 105 <td align="right"><?php echo $AppUI->_('Phone'); ?>:</td> 106 <td> 107 <input type="text" class="text" name="company_phone1" value="<?php echo w2PformSafe($obj->company_phone1); ?>" maxlength="30" /> 108 </td> 109 </tr> 110 <tr> 111 <td align="right"><?php echo $AppUI->_('Phone'); ?>2:</td> 112 <td> 113 <input type="text" class="text" name="company_phone2" value="<?php echo w2PformSafe($obj->company_phone2); ?>" maxlength="50" /> 114 </td> 115 </tr> 116 <tr> 117 <td align="right"><?php echo $AppUI->_('Fax'); ?>:</td> 118 <td> 119 <input type="text" class="text" name="company_fax" value="<?php echo w2PformSafe($obj->company_fax); ?>" maxlength="30" /> 120 </td> 121 </tr> 122 <tr> 123 <td colspan="2" align="center"> 124 <img src="<?php echo w2PfindImage('shim.gif'); ?>" width="50" height="1" /><?php echo $AppUI->_('Address'); ?><br /> 125 <hr width="500" align="center" size="1" /> 126 </td> 127 </tr> 128 <tr> 129 <td align="right"><?php echo $AppUI->_('Address'); ?>1:</td> 130 <td><input type="text" class="text" name="company_address1" value="<?php echo w2PformSafe($obj->company_address1); ?>" size="50" maxlength="255" /></td> 131 </tr> 132 <tr> 133 <td align="right"><?php echo $AppUI->_('Address'); ?>2:</td> 134 <td><input type="text" class="text" name="company_address2" value="<?php echo w2PformSafe($obj->company_address2); ?>" size="50" maxlength="255" /></td> 135 </tr> 136 <tr> 137 <td align="right"><?php echo $AppUI->_('City'); ?>:</td> 138 <td><input type="text" class="text" name="company_city" value="<?php echo w2PformSafe($obj->company_city); ?>" size="50" maxlength="50" /></td> 139 </tr> 140 <tr> 141 <td align="right"><?php echo $AppUI->_('State'); ?>:</td> 142 <td><input type="text" class="text" name="company_state" value="<?php echo w2PformSafe($obj->company_state); ?>" maxlength="50" /></td> 143 </tr> 144 <tr> 145 <td align="right"><?php echo $AppUI->_('Zip'); ?>:</td> 146 <td><input type="text" class="text" name="company_zip" value="<?php echo w2PformSafe($obj->company_zip); ?>" maxlength="15" /></td> 147 </tr> 148 <tr> 149 <td align="right"><?php echo $AppUI->_('Country'); ?>:</td> 150 <td> 151 <?php 152 echo arraySelect($countries, 'company_country', 'size="1" class="text"', $obj->company_country ? $obj->company_country : 0); 153 ?> 154 </td> 155 </tr> 156 <tr> 157 <td align="right"> 158 URL http://<a name="x"></a></td><td><input type="text" class="text" value="<?php echo w2PformSafe($obj->company_primary_url); ?>" name="company_primary_url" size="50" maxlength="255" /> 159 <a href="javascript: void(0);" onclick="testURL('CompanyURLOne')">[<?php echo $AppUI->_('test'); ?>]</a> 160 </td> 161 </tr> 162 163 <tr> 164 <td align="right"><?php echo $AppUI->_('Company Owner'); ?>:</td> 165 <td> 166 <?php 167 echo arraySelect($owners, 'company_owner', 'size="1" class="text"', $obj->company_owner ? $obj->company_owner : $AppUI->user_id); 168 ?> 169 </td> 170 </tr> 171 172 <tr> 173 <td align="right"><?php echo $AppUI->_('Type'); ?>:</td> 174 <td> 175 <?php 176 echo arraySelect($types, 'company_type', 'size="1" class="text"', $obj->company_type, true); 177 ?> 178 </td> 179 </tr> 180 181 <tr> 182 <td align="right" valign="top"><?php echo $AppUI->_('Description'); ?>:</td> 183 <td align="left"> 184 <textarea cols="70" rows="10" class="textarea" name="company_description"><?php echo $obj->company_description; ?></textarea> 185 </td> 186 </tr> 187 </table> 188 189 190 </td> 191 <td align='left'> 192 <?php 193 require_once ($AppUI->getSystemClass('CustomFields')); 194 $custom_fields = new CustomFields($m, $a, $obj->company_id, "edit"); 195 $custom_fields->printHTML(); 196 ?> 197 </td> 198 </tr> 199 <tr> 200 <td><input type="button" value="<?php echo $AppUI->_('back'); ?>" class="button" onclick="javascript:history.back(-1);" /></td> 201 <td align="right"><input type="button" value="<?php echo $AppUI->_('submit'); ?>" class="button" onclick="submitIt()" /></td> 202 </tr> 203 </form> 204 </table>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 7 03:00:01 2009 | Cross-referenced by PHPXref 0.7 |