fetchArray( $query ); $idanagrafica = $rs[0]['idanagrafica']; $idcliente = $rs[0]['idanagrafica']; $idsede = $rs[0]['sedeop']; $str_cash = 0.00; $quer_riga="Select * from in_interventi_tecnici WHERE id='".$idriga."'"; $rs_riga = $dbo->fetchArray( $quer_riga ); //Leggo il nome del referente se selezionato da menu a tendina if( $rs[0]['idreferente'] != '0' ){ $rs2 = $dbo->fetchArray("SELECT * FROM an_referenti WHERE id=\"".$rs[0]['idreferente']."\""); $referente = $rs2[0]['nome']; } else { $referente = $rs[0]['referente']." ".$rs[0]['telefono_referente']; } //carica report html $report = file_get_contents ($docroot."/templates/interventi/intervento.html"); $body = file_get_contents ($docroot."/templates/interventi/intervento_body.html"); include_once( $docroot."/templates/pdfgen_variables.php" ); // imposta numerointervento-data-numerocommessa su intestazione $body = str_replace( '$intervento_numero$', $rs[0]['idintervento'], $body ); $body = str_replace( '$intervento_data$', date( "d/m/Y", strtotime($rs[0]['data_richiesta']) ), $body ); if( $rs[0]['numero_preventivo'] ) $body = str_replace( '$commessa_numero$', $rs[0]['idintervento'], $body ); else $body = str_replace( '$commessa_numero$', " ", $body ); $body = str_replace( '$commessa_numero$', $rs[0]['idintervento'], $body ); /* Dati intervento */ $body .= "\n"; $body .= "\n"; $body .= ""; $body .= " \n"; $body .= " \n"; $body .= "\n"; // appunti $body .= "\n"; $body .= " \n"; $body .= "\n"; $body .= "\n"; $body .= " \n"; $body .= "\n"; $body .= "
\n"; $body .= " Cliente: ".$c_codiceanagrafica." ".$c_ragionesociale."
\n"; $body .= " Indirizzo: ".$c_indirizzo." - ".$c_cap." ".$c_citta." (".strtoupper ($c_provincia).")
\n"; if ( $idsede != "0" ){ $rs_sede = $dbo->fetchArray("SELECT * FROM an_sedi WHERE id='". $idsede."'"); $body .= " Sede: ".$rs_sede[0]['nomesede']."
\n"; $body .= " ".$rs_sede[0]['indirizzo']." - ".$rs_sede[0]['cap']." ".$rs_sede[0]['citta']."
\n"; } $body .= "
\n"; $body .= " Ordine di Servizio: ".$rs[0]['idintervento']."
\n"; $body .= " Matricola Impianto: ".$rs_riga[0]['matricola_impianto']."
\n"; //$body .= " Referente: ".$referente."\n"; if( $c_telefono!='' ) $body .= "Telefono azienda: ".$c_telefono."\n"; if( $c_email!='' ) $body .= "
Email: ".$c_email."\n"; $body .= "
Appunti:
".nl2br($rs_riga[0]['descrizione_att'])."
\n"; //Conteggio prezzi $costo_orario = $rs[0]['costo_orario']; $totale_ore_consuntivo = $rs[0]['tot_ore_consuntivo'] - $rs[0]['tot_dirittochiamata']; $totale_km_consuntivo = $rs[0]['tot_km_consuntivo']; $totale_dirittochiamata = $rs[0]['tot_dirittochiamata']; $totale_intervento = $totale_ore_consuntivo + $totale_km_consuntivo + $totale_dirittochiamata; //visualizzo costi? if(( $totale_intervento != 0.00 ) and ($visualizza_costi==true)){ $colspan = 2; if( $totale_ore_consuntivo != 0 ){ $colspan--; } if( $totale_km_consuntivo != 0 ){ $colspan--; } } //MATERIALE UTILIZZATO //Conteggio articoli utilizzati $query = "SELECT *, (SELECT codice FROM mg_articoli WHERE id=idarticolo) AS codice_art, SUM(qta) AS sumqta FROM `mg_articoli_interventi` where idintervento=\"".$idintervento."\" AND NOT idarticolo='0' and idriga_pianifica='".$idriga."' GROUP BY idarticolo, idintervento, lotto ORDER BY idarticolo ASC"; $rs2 = $dbo->fetchArray($query); if( sizeof($rs2)>0 ){ $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $totale_articoli = 0.00; for( $i=0; $i\n"; $body .= "\n"; //Descrizione $body .= "\n"; //Quantità $qta = $rs2[$i]['sumqta']; $body .= "\n"; //Prezzo unitario $netto = $rs2[$i]['prezzo_vendita']; $body .= "\n"; //Sconto unitario if( $rs2[$i]['sconto_prc'] != 0 ){ $sconto = number_format( $rs2[$i]['sconto_prc'], 0, ",", "" )."%"; } elseif( $rs2[$i]['sconto'] != 0 ) { $sconto = number_format( $rs2[$i]['sconto'], 2, ",", "" )." &euro"; $netto = $rs2[$i]['prezzo_vendita']; } else { $sconto = "-"; } $body .= "\n"; //Netto $netto = ( $rs2[$i]['prezzo_vendita'] - $rs2[$i]['sconto'] ) * $rs2[$i]['sumqta']; $body .= "\n"; //Totale $totale_articoli += $netto; $body .= "\n"; } //TOTALE MATERIALE UTILIZZATO if ($visualizza_costi==true){ //Totale spesa articoli $body .= "\n"; $body .= "\n"; } $body .= "
MATERIALE UTILIZZATO
\n"; $body .= "Codice\n"; $body .= "\n"; $body .= "Descrizione\n"; $body .= "\n"; $body .= "Q.tà\n"; $body .= "\n"; $body .= "Prezzo listino\n"; $body .= " \n"; $body .= "\n"; // $body .= "Sconto\n"; $body .= " \n"; $body .= "\n"; $body .= "Subtot. netto\n"; $body .= " \n"; $body .= "
\n"; $body .= "".$rs2[$i]['descrizione']."\n"; //if( $rs2[$i]['codice']!='' && $rs2[$i]['codice']!='Lotto: , SN: , Altro: ' ){ $body .= "
".$rs2[$i]['codice']."\n"; } $body .= "
\n"; $body .= "".number_format( $rs2[$i]['sumqta'], 2, ",", "." )." ".$rs2[$i]['um']."\n"; $body .= "\n"; if ($visualizza_costi==true){ $body .= "".number_format( $netto, 2, ",", "" )." €\n"; } else { $body .= " \n"; } $body .= "\n"; if ($visualizza_costi==true){ $body .= "".$sconto."\n"; } else { $body .= " \n"; } $body .= "\n"; if ($visualizza_costi==true){ $body .= "".number_format( $netto, 2, ",", "" )."\n"; } else { $body .= " \n"; } $body .= "
\n"; $body .= "TOTALE MATERIALE UTILIZZATO:\n"; $body .= "\n"; $body .= "".number_format( $totale_articoli, 2, ",", ".")." €\n"; $body .= "
\n"; } //FINE MATERIALE UTILIZZATO //Conteggio SPESE AGGIUNTIVE $query = "SELECT * FROM in_righe_interventi WHERE idintervento='".$idintervento."' and idriga_pianifica='".$idriga."' ORDER BY id ASC"; $rs2 = $dbo->fetchArray($query); if( sizeof($rs2)>0 ){ $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $body .= "\n"; $totale_righe = 0.00; for( $i=0; $i\n"; $body .= "\n"; //Quantità $body .= "\n"; //Prezzo unitario $netto = $rs2[$i]['prezzo_vendita']; $body .= "\n"; //Sconto unitario if( $rs2[$i]['sconto_prc'] != 0 ){ $sconto = number_format( $rs2[$i]['sconto_prc'], 0, ",", "" )."%"; } elseif( $rs2[$i]['sconto'] != 0 ) { $sconto = number_format( $rs2[$i]['sconto'], 2, ",", "" )." &euro"; $netto = $rs2[$i]['prezzo_vendita']; } else { $sconto = "-"; } $body .= "\n"; //Prezzo totale $netto = ( $rs2[$i]['prezzo_vendita'] - $rs2[$i]['sconto'] ) * $rs2[$i]['qta']; $body .= "\n"; //Subtot $totale_righe += $netto; } if ($visualizza_costi==true){ //Totale spese aggiuntive $body .= "\n"; $body .= "\n"; } $body .= "
SPESE AGGIUNTIVE
\n"; $body .= "\n"; $body .= "\n"; $body .= "Descrizione\n"; $body .= "\n"; $body .= "Q.tà\n"; $body .= "\n"; $body .= "Spesa\n"; $body .= "\n"; // $body .= "Sconto\n"; $body .= "\n"; $body .= "\n"; $body .= "Totale\n"; $body .= "
\n"; $body .= "".number_format( $rs2[$i]['qta'], 2, ",", "" )."\n"; $body .= "\n"; if ($visualizza_costi==true){ $body .= "".number_format( $netto, 2, ",", "" )." €\n"; } else { $body .= " - \n"; } $body .= "\n"; if ($visualizza_costi==true){ $body .= "".$sconto."\n"; } else { $body .= " - \n"; } $body .= "\n"; // if ($visualizza_costi==true){ $body .= "".number_format( $netto, 2, ",", "" )." €\n"; // } else { // $body .= " - \n"; // } $body .= "
\n"; $body .= "TOTALE SPESE AGGIUNTIVE:\n"; $body .= "\n"; $body .= "".number_format( $totale_righe, 2, ",", ".")." €\n"; $body .= "
\n"; } //FINE SPESE AGGIUNTIVE //ORE TECNICI + FIRMA $body .= "\n"; $body .= "\n"; $body .= "\n"; //INTESTAZIONE ELENCO TECNICI $body .= ""; $body .= ""; $body .= ""; $body .= ""; $body .= "\n"; // sessioni di lavoro dei tecnici $qt = "SELECT *, in_interventi_tecnici.km AS km_tecnico FROM in_interventi INNER JOIN (in_interventi_tecnici INNER JOIN an_anagrafiche ON in_interventi_tecnici.idtecnico=an_anagrafiche.idanagrafica) ON in_interventi.idintervento=in_interventi_tecnici.idintervento WHERE in_interventi.idintervento='$idintervento' and in_interventi_tecnici.id ='$idriga' ORDER BY in_interventi_tecnici.orario_inizio "; $rst = $dbo->fetchArray( $qt ); $nt = sizeof($rst); for( $t=0; $t<$nt; $t++ ){ $body .= "\n"; //nome tecnico $body .= " "; //ora inizio $body .= " "; //ora fine $body .= " "; //data $body .= " "; $body .= "\n"; } $body .= "
PIANIFICAZIONE
"; $body .= "Operatore"; $body .= ""; $body .= "Dalle"; $body .= ""; $body .= "Alle"; $body .= ""; $body .= "Data"; $body .= "
\n"; $body .= " ".$rst[$t]['ragione_sociale'].""; $body .= " "; if ($rst[$t]['orario_inizio']!='00:00:00'){ $body .= "".readDateTimePrint($rst[$t]['orario_inizio'], 'time').""; }else{ $body .= " - "; } $body .= " "; if ($rst[$t]['orario_fine']!='00:00:00'){ $body .= "".readDateTimePrint($rst[$t]['orario_fine'], 'time').""; }else{ $body .= " - "; } $body .= " "; if ($rst[$t]['orario_inizio']!='00:00:00'){ $body .= "".readDateTimePrint($rst[$t]['orario_inizio'], 'date').""; }else{ $body .= " - "; } $body .= "
\n"; // timbro e firma if( $rs_riga[0]['firma_file'] != '' ){ $firma = "\n"; } else { $firma = ""; } $body .= "
\n"; $body .= "\n"; $body .= "\n"; $body .= " \n"; $body .= " "; $body .= "\n"; $body .= "
\n"; $body .= " "; $body .= " ".$firma."
\n"; $body .= " (Timbro e firma leggibile.)"; $body .= "
\n"; $report_name = "intervento_".$idintervento.".pdf"; ?>