You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							149 lines
						
					
					
						
							7.4 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							149 lines
						
					
					
						
							7.4 KiB
						
					
					
				| <div class="row"> | |
|     <div class="col-12"> | |
|         <div class="section-title">Modifica inserzione</div> | |
|     </div> | |
|     <div class="col-12"> | |
| 
 | |
|         <div class="sheet-box p-4"> | |
| 
 | |
|         <?php | |
|             if($_POST['go']){ | |
| 
 | |
|                 $append = ''; | |
| 
 | |
|                 if(is_uploaded_file($_FILES['append']['tmp_name'])){ | |
|                     $filename = date("YmdHis")."-".preg_replace('/[^a-zA-Z0-9\-\._]/','_', $_FILES['append']['name']); | |
|                     $filesize = ($_FILES['append']['size'] < 1000000) ? round($_FILES['append']['size'] / 1000)."k" : round($_FILES['append']['size'] / 1000000)."M"; | |
|                     $path = '/docs/files/advertisement'; | |
|                     move_uploaded_file($_FILES['append']['tmp_name'], "..$path/$filename"); | |
|                     $qf=mysqli_query($conn, "INSERT INTO files VALUES(null, '$filename', '$filename', '".$path."', NOW(), '$filesize')"); | |
|                     $append = "append='".mysqli_insert_id($conn)."', "; | |
|                 } | |
| 
 | |
|                 $q=mysqli_query($conn, "UPDATE advertisement SET | |
|                                         full_name='".addslashes(trim($_POST['full_name']))."', | |
|                                         email='".addslashes(trim($_POST['email']))."', | |
|                                         date='".trim(conv_date_en($_POST['date']))."', | |
|                                         text='".addslashes(nl2br($_POST['text']))."', | |
|                                         city='".addslashes(trim($_POST['city']))."', | |
|                                         contact_phone='".addslashes(trim($_POST['contact_phone']))."', | |
|                                         contact_phone='".addslashes(trim($_POST['contact_email']))."', | |
|                                         $append | |
|                                         type='".$_POST['type']."', | |
|                                         enabled=".$_POST['enabled']." WHERE id=".trim($getQ[3])); | |
| 
 | |
| 
 | |
|                 echo '<div class="col-10 text-center mx-auto my-5"> | |
|                         <p><i class="fa fa-check-circle font-alert p-4"></i></p> | |
|                         Inserzione modificata correttamente! | |
|                     </div>'; | |
| 
 | |
|             }else{ | |
| 
 | |
|                 if($getQ[3]){ | |
| 
 | |
|                 $q=mysqli_query($conn, "SELECT * FROM advertisement WHERE id = ".trim($getQ[3])); | |
|                 $r=mysqli_fetch_array($q); | |
| 
 | |
|                 $appendLink = '<span class="font-12">Nessun allegato presente.</span>'; | |
|                 if($r['append']) { | |
|                   $qa=mysqli_query($conn, "SELECT * FROM files WHERE id = ".$r['append']); | |
|                   $ra=mysqli_fetch_array($qa); | |
|                   $appendLink = '<a class="font-12" href="'.$BASE_URL.'/..'.$ra['path'].'/'.$ra['filename'].'">'.$ra['filename'].'</a>'; | |
|                 } | |
| 
 | |
|         ?> | |
|  | |
|             <form method="post" enctype="multipart/form-data"> | |
|                 <div class="row"> | |
|                     <div class="col-12 col-sm-6"> | |
|                         <span class="font-12">Tipologia inserzione</span> | |
|                         <select class="input" name="type"> | |
|                             <option value="find" <?php if($r['type']=="find"){echo "selected";}?>>Cerco lavoro</option> | |
|                             <option value="offer" <?php if($r['type']=="offer"){echo "selected";}?>>Offro lavoro</option> | |
|                             <option value="adv" <?php if($r['type']=="adv"){echo "selected";}?>>Annunci di compravendita</option> | |
|                         </select> | |
|                     </div> | |
|                     <div class="col-12 col-sm-6"> | |
|                         <span class="font-12">Data</span> | |
|                         <input type="text" name="date" class="datepicker" value="<?= conv_date($r['date']);?>"> | |
|                     </div> | |
|  | |
|                     <div class="col-12"> | |
|                         <span class="font-12">Nome e Cognome</span> | |
|                         <input type="text" name="full_name" value="<?= $r['full_name'];?>"> | |
|                     </div> | |
|                     <div class="col-12"> | |
|                         <span class="font-12">Testo inserzione</span> | |
|                         <textarea cols="40" rows="6" name="text"><?= strip_tags($r['text']);?></textarea> | |
|                     </div> | |
|                     <div class="col-12"> | |
|                         <span class="font-12">Comune di residenza*</span> | |
|                         <input type="text" name="city" value="<?= $r['city'];?>"> | |
|                     </div> | |
|                     <div class="col-12 col-sm-6"> | |
|                         <span class="font-12">Recapiti telefonici*</span> | |
|                         <input type="text" name="contact_phone" value="<?= $r['contact_phone'];?>"> | |
|                     </div> | |
|                     <div class="col-12 col-sm-6"> | |
|                         <span class="font-12">Email contatto*</span> | |
|                         <input type="text" name="contact_email" value="<?= $r['contact_email'];?>" > | |
|                     </div> | |
|                     <div class="col-12 col-sm-6"> | |
|                         <span class="font-12">Allegato (opzionale, ES: curriculum)</span><br> | |
|                         <input type="file" name="append"> | |
|                         <?= $appendLink; ?> | |
|                     </div> | |
|                     <div class="col-12 col-sm-6"> | |
|                         <span class="font-12">Stato inserzione</span> | |
|                         <select class="input" name="enabled"> | |
|                             <option value="0" <?php if($r['enabled']==0){echo "selected";}?>>NON abilitata</option> | |
|                             <option value="1" <?php if($r['enabled']==1){echo "selected";}?>>Abilitata</option> | |
|                         </select> | |
|                     </div> | |
|                     <div class="col-12 text-right"> | |
|                         <button type="submit" name="go" value="1">Modifica inserzione</button> | |
|                     </div> | |
|                 </div> | |
|             </form> | |
|  | |
|             <?php | |
|                     }else{ | |
|  | |
|                     ?> | |
|                         <form method="post" class="form-mod" data-path="<?= $BASE_URL;?>/sheets/advertisement/mod"> | |
|                             <div class="col-12 col-sm-10 mx-auto"> | |
|                                 <div class="row"> | |
|                                     <div class="col"> | |
|                                         <span class="font-12">Seleziona una inserzione</span> | |
|                                     </div> | |
|                                 </div> | |
|                                 <div class="row"> | |
|                                     <div class="col"> | |
|                                         <select name="id" class="id"> | |
|                                         <?php | |
|                                             $qn=mysqli_query($conn, "SELECT * FROM advertisement ORDER BY date DESC"); | |
|                                             while($rn=mysqli_fetch_array($qn)){ | |
|                                                 echo "<option value=\"".$rn['id']."\">".conv_date($rn['date'])." - ".$rn['full_name']."</option>"; | |
|                                             } | |
|                                         ?> | |
|                                         </select> | |
|                                     </div> | |
|                                     <div class="col-auto"> | |
|                                         <button type="submit">Modifica</button> | |
|                                     </div> | |
|                                 </div> | |
|                             </div> | |
|                         </form> | |
|  | |
|                     <?php | |
|  | |
|                     } | |
|                 } | |
|             ?> | |
|  | |
|         </div> | |
|  | |
|     </div> | |
| </div> | |
| 
 |